Get a basic Flake setup

This commit is contained in:
Greg Hellings
2024-10-15 16:54:57 -05:00
commit 7f97b1ed9f
7 changed files with 297 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
use flake
+2
View File
@@ -0,0 +1,2 @@
/target
.direnv
Generated
+7
View File
@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rustdoku"
version = "0.1.0"
+6
View File
@@ -0,0 +1,6 @@
[package]
name = "rustdoku"
version = "0.1.0"
edition = "2021"
[dependencies]
Generated
+140
View File
@@ -0,0 +1,140 @@
{
"nodes": {
"devshell": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1728330715,
"narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=",
"owner": "numtide",
"repo": "devshell",
"rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1727826117,
"narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-root": {
"locked": {
"lastModified": 1723604017,
"narHash": "sha256-rBtQ8gg+Dn4Sx/s+pvjdq3CB2wQNzx9XGFq/JVGCB6k=",
"owner": "srid",
"repo": "flake-root",
"rev": "b759a56851e10cb13f6b8e5698af7b59c44be26e",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "flake-root",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1721727458,
"narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=",
"owner": "nix-community",
"repo": "naersk",
"rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1722073938,
"narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1727825735,
"narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 0,
"narHash": "sha256-HP89HZOT0ReIbI7IJZJQoJgxvB2Tn28V6XS3MNKnfLs=",
"path": "/nix/store/lryfc8mhk1czqsa421di2y5nzz5c3b8m-source",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1728538411,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devshell": "devshell",
"flake-parts": "flake-parts",
"flake-root": "flake-root",
"naersk": "naersk",
"nixpkgs": "nixpkgs_3"
}
}
},
"root": "root",
"version": 7
}
+78
View File
@@ -0,0 +1,78 @@
# github.com/brianmcgee has lots of great ideas for going above and beyond for this
{
description = "Greg's homepage";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devshell.url = "github:numtide/devshell";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
naersk.url = "github:nix-community/naersk";
#process-compose.url = "github:Platonic-Systems/process-compose-flake";
#services-flake.url = "github:juspay/services-flake";
};
outputs = { flake-parts, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devshell.flakeModule
inputs.flake-root.flakeModule
#inputs.process-compose.flakeModule
];
flake = {
# Universal things
overlays.default = final: prev: {};
};
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
perSystem = { pkgs, ... }@inputs': let
naersk-lib = pkgs.callPackage inputs.naersk { };
in {
_module.args.pkgs = import inputs.nixpkgs {
inherit (inputs') system;
overlays = [];
};
# https://numtide.github.io/devshell/intro.html
devshells.default = {
env = [{
name = "RUST_SRC_PATH";
value = pkgs.rustPlatform.rustLibSrc;
}];
# These commands will be shown in the motd that users read
# upon entering the shell
commands = [{
package = pkgs.cargo;
category = "languages";
help = "The Cargo tool";
} {
package = pkgs.rustc;
category = "languages";
help = "The rust compiler";
} {
package = pkgs.rustfmt;
category = "tools";
help = "Formatting tool for Rust";
} {
package = pkgs.pre-commit;
category = "tools";
help = "Helps run certain checks";
} {
package = pkgs.rustPackages.clippy;
category = "tools";
help = "Standard Rust clippy tool";
} {
package = pkgs.stdenv.cc;
category = "languages";
help = "The C compiler, to help things out";
}];
};
# This is not special, this is just flakes
packages = {
default = naersk-lib.buildPackage ./.;
};
};
};
}
+63
View File
@@ -0,0 +1,63 @@
#[derive(Clone,Debug,Copy)]
pub enum CellValue {
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine
}
pub struct Cell {
value: Option<CellValue>,
candidates: Vec<CellValue>,
}
impl Default for Cell {
fn default() -> Cell {
Cell {
value : None,
candidates : vec![
CellValue::One,
CellValue::Two,
CellValue::Three,
CellValue::Four,
CellValue::Five,
CellValue::Six,
CellValue::Seven,
CellValue::Eight,
CellValue::Nine
]
}
}
}
#[derive(Default)]
pub struct Board {
cells: [ [ Cell ; 9 ] ; 9 ]
}
impl Board {
fn value(self, x: usize, y : usize) -> Option<CellValue> {
self.cells[x][y].value
}
}
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}