Base scaffold

This commit is contained in:
Greg Hellings
2024-10-15 19:57:26 -05:00
parent 7f97b1ed9f
commit c31d638dc0
5 changed files with 213 additions and 85 deletions
+1
View File
@@ -1,2 +1,3 @@
/target /target
.direnv .direnv
result
+8
View File
@@ -0,0 +1,8 @@
phases:
- check
check:
tags:
- nix
script:
- nix flake check
Generated
+94 -3
View File
@@ -18,6 +18,22 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
@@ -51,9 +67,51 @@
"type": "github" "type": "github"
} }
}, },
"gitignore": {
"inputs": {
"nixpkgs": [
"hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1728778939,
"narHash": "sha256-WybK5E3hpGxtCYtBwpRj1E9JoiVxe+8kX83snTNaFHE=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "ff68f91754be6f3427e4986d7949e6273659be1d",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"naersk": { "naersk": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1721727458, "lastModified": 1721727458,
@@ -97,7 +155,39 @@
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
} }
}, },
"nixpkgs-stable": {
"locked": {
"lastModified": 1720386169,
"narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "194846768975b7ad2c4988bdb82572c00222c0d7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"locked": {
"lastModified": 1719082008,
"narHash": "sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9693852a2070b398ee123a329e68f0dab5526681",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": { "locked": {
"lastModified": 0, "lastModified": 0,
"narHash": "sha256-HP89HZOT0ReIbI7IJZJQoJgxvB2Tn28V6XS3MNKnfLs=", "narHash": "sha256-HP89HZOT0ReIbI7IJZJQoJgxvB2Tn28V6XS3MNKnfLs=",
@@ -109,7 +199,7 @@
"type": "indirect" "type": "indirect"
} }
}, },
"nixpkgs_3": { "nixpkgs_4": {
"locked": { "locked": {
"lastModified": 1728538411, "lastModified": 1728538411,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
@@ -130,8 +220,9 @@
"devshell": "devshell", "devshell": "devshell",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"flake-root": "flake-root", "flake-root": "flake-root",
"hooks": "hooks",
"naersk": "naersk", "naersk": "naersk",
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_4"
} }
} }
}, },
+102 -73
View File
@@ -1,78 +1,107 @@
# github.com/brianmcgee has lots of great ideas for going above and beyond for this # github.com/brianmcgee has lots of great ideas for going above and beyond for this
{ {
description = "Greg's homepage"; description = "Greg's homepage";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devshell.url = "github:numtide/devshell"; devshell.url = "github:numtide/devshell";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root"; flake-root.url = "github:srid/flake-root";
naersk.url = "github:nix-community/naersk"; hooks.url = "github:cachix/git-hooks.nix";
#process-compose.url = "github:Platonic-Systems/process-compose-flake"; naersk.url = "github:nix-community/naersk";
#services-flake.url = "github:juspay/services-flake"; };
};
outputs = { flake-parts, ... }@inputs: outputs =
flake-parts.lib.mkFlake { inherit inputs; } { { flake-parts, ... }@inputs:
imports = [ flake-parts.lib.mkFlake { inherit inputs; } {
inputs.devshell.flakeModule imports = [
inputs.flake-root.flakeModule inputs.devshell.flakeModule
#inputs.process-compose.flakeModule inputs.flake-root.flakeModule
]; #inputs.process-compose.flakeModule
flake = { ];
# Universal things flake = {
overlays.default = final: prev: {}; # Universal things
}; # final: prev:
systems = [ overlays.default = _: _: { };
"x86_64-linux" };
"aarch64-linux" systems = [
"aarch64-darwin" "x86_64-linux"
]; "aarch64-linux"
perSystem = { pkgs, ... }@inputs': let "aarch64-darwin"
naersk-lib = pkgs.callPackage inputs.naersk { }; ];
in { perSystem =
_module.args.pkgs = import inputs.nixpkgs { { pkgs, ... }@inputs':
inherit (inputs') system; let
overlays = []; naersk-lib = pkgs.callPackage inputs.naersk { };
}; in
# https://numtide.github.io/devshell/intro.html {
devshells.default = { _module.args.pkgs = import inputs.nixpkgs {
env = [{ inherit (inputs') system;
name = "RUST_SRC_PATH"; overlays = [ ];
value = pkgs.rustPlatform.rustLibSrc; };
}]; # https://numtide.github.io/devshell/intro.html
# These commands will be shown in the motd that users read devshells.default = {
# upon entering the shell # These commands will be shown in the motd that users read
commands = [{ # upon entering the shell
package = pkgs.cargo; commands = [
category = "languages"; {
help = "The Cargo tool"; package = pkgs.cargo;
} { category = "tools";
package = pkgs.rustc; help = "Rust build and package tool";
category = "languages"; }
help = "The rust compiler"; {
} { package = pkgs.rustc;
package = pkgs.rustfmt; category = "languages";
category = "tools"; help = "Rust compiler";
help = "Formatting tool for Rust"; }
} { {
package = pkgs.pre-commit; package = pkgs.rustfmt;
category = "tools"; category = "tools";
help = "Helps run certain checks"; help = "Standard Rust formatting tool";
} { }
package = pkgs.rustPackages.clippy; {
category = "tools"; package = pkgs.clippy;
help = "Standard Rust clippy tool"; category = "tools";
} { help = "Rust linter";
package = pkgs.stdenv.cc; }
category = "languages"; {
help = "The C compiler, to help things out"; package = pkgs.stdenv.cc;
}]; category = "languages";
}; help = "C compiler to help with building native code";
}
{
package = pkgs.pre-commit;
category = "tools";
help = "Tool to help enforce commits make sense";
}
];
};
# This is not special, this is just flakes checks = {
packages = { pre-commit-check = inputs.hooks.lib.${inputs'.system}.run {
default = naersk-lib.buildPackage ./.; src = ./.;
}; hooks = {
}; check-added-large-files.enable = true;
}; check-case-conflicts.enable = true;
check-merge-conflicts.enable = true;
check-symlinks.enable = true;
deadnix.enable = true;
end-of-file-fixer.enable = true;
fix-byte-order-marker.enable = true;
mixed-line-endings.enable = true;
nixfmt-rfc-style.enable = true;
trim-trailing-whitespace.enable = true;
# Rust hooks
cargo-check.enable = true;
clippy.enable = true;
rustfmt.enable = true;
};
};
};
# This is not special, this is just flakes
packages = {
rustpkg = naersk-lib.buildPackage ./.;
};
};
};
} }
+8 -9
View File
@@ -1,4 +1,4 @@
#[derive(Clone,Debug,Copy)] #[derive(Clone, Debug, Copy)]
pub enum CellValue { pub enum CellValue {
One, One,
Two, Two,
@@ -8,20 +8,19 @@ pub enum CellValue {
Six, Six,
Seven, Seven,
Eight, Eight,
Nine Nine,
} }
pub struct Cell { pub struct Cell {
value: Option<CellValue>, value: Option<CellValue>,
candidates: Vec<CellValue>, candidates: Vec<CellValue>,
} }
impl Default for Cell { impl Default for Cell {
fn default() -> Cell { fn default() -> Cell {
Cell { Cell {
value : None, value: None,
candidates : vec![ candidates: vec![
CellValue::One, CellValue::One,
CellValue::Two, CellValue::Two,
CellValue::Three, CellValue::Three,
@@ -30,19 +29,19 @@ impl Default for Cell {
CellValue::Six, CellValue::Six,
CellValue::Seven, CellValue::Seven,
CellValue::Eight, CellValue::Eight,
CellValue::Nine CellValue::Nine,
] ],
} }
} }
} }
#[derive(Default)] #[derive(Default)]
pub struct Board { pub struct Board {
cells: [ [ Cell ; 9 ] ; 9 ] cells: [[Cell; 9]; 9],
} }
impl Board { impl Board {
fn value(self, x: usize, y : usize) -> Option<CellValue> { fn value(self, x: usize, y: usize) -> Option<CellValue> {
self.cells[x][y].value self.cells[x][y].value
} }
} }