chore: init nix flake and cargo workspace
This commit is contained in:
commit
b696670112
12 changed files with 203 additions and 0 deletions
2
.envrc
Normal file
2
.envrc
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
nix_direnv_manual_reload
|
||||||
|
use flake
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/target
|
||||||
|
/result
|
||||||
|
/.direnv
|
||||||
|
/.pre-commit-config.yaml
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lyt"
|
||||||
|
version = "0.1.0"
|
3
Cargo.toml
Normal file
3
Cargo.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[workspace]
|
||||||
|
resolver = "2"
|
||||||
|
members = ["lyt"]
|
87
flake.lock
generated
Normal file
87
flake.lock
generated
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"git-hooks": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"gitignore": "gitignore",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1737465171,
|
||||||
|
"narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitignore": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"git-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"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1739206421,
|
||||||
|
"narHash": "sha256-PwQASeL2cGVmrtQYlrBur0U20Xy07uSWVnFup2PHnDs=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "44534bc021b85c8d78e465021e21f33b856e2540",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-24.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"git-hooks": "git-hooks",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
14
flake.nix
Normal file
14
flake.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
|
||||||
|
inputs.git-hooks.url = "github:cachix/git-hooks.nix";
|
||||||
|
inputs.git-hooks.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
outputs = inputs: let
|
||||||
|
inherit (import nix/boilerplate.nix inputs) call genPkgs;
|
||||||
|
in {
|
||||||
|
# overlays = import nix/overlays.nix;
|
||||||
|
packages = call (import nix/packages.nix);
|
||||||
|
checks = call (import nix/checks.nix);
|
||||||
|
devShells = call (import nix/shells.nix);
|
||||||
|
formatter = genPkgs (p: p.alejandra);
|
||||||
|
};
|
||||||
|
}
|
6
lyt/Cargo.toml
Normal file
6
lyt/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "lyt"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
3
lyt/src/main.rs
Normal file
3
lyt/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
17
nix/boilerplate.nix
Normal file
17
nix/boilerplate.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
inputs @ {
|
||||||
|
nixpkgs,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
forSelfOverlay =
|
||||||
|
if builtins.hasAttr "overlays" self && builtins.hasAttr "forSelf" self.overlays
|
||||||
|
then self.overlays.forSelf
|
||||||
|
else (_: p: p);
|
||||||
|
in rec {
|
||||||
|
# TODO: Iterate all Nix's supported systems?
|
||||||
|
systems = ["aarch64-linux" "x86_64-linux" "x86_64-darwin" "aarch64-darwin"];
|
||||||
|
forSystems = nixpkgs.lib.genAttrs systems;
|
||||||
|
pkgsFor = system: ((import nixpkgs {inherit system;}).extend forSelfOverlay);
|
||||||
|
genPkgs = func: (forSystems (system: func (pkgsFor system)));
|
||||||
|
call = imported: genPkgs (pkgs: imported (inputs // {inherit pkgs;}));
|
||||||
|
}
|
25
nix/checks.nix
Normal file
25
nix/checks.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
git-hooks,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
git-hooks = git-hooks.lib.${pkgs.system}.run {
|
||||||
|
src = ./..;
|
||||||
|
hooks = {
|
||||||
|
alejandra.enable = true;
|
||||||
|
cargo-check.enable = true;
|
||||||
|
convco.enable = true;
|
||||||
|
cargo-test = {
|
||||||
|
enable = true;
|
||||||
|
name = "cargo-test";
|
||||||
|
entry = "cargo test";
|
||||||
|
# types = ["rust"];
|
||||||
|
# language = "rust";
|
||||||
|
pass_filenames = false;
|
||||||
|
stages = ["pre-commit"];
|
||||||
|
};
|
||||||
|
clippy.enable = true;
|
||||||
|
rustfmt.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
14
nix/packages.nix
Normal file
14
nix/packages.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{pkgs, ...}: let
|
||||||
|
inherit (builtins) fromTOML readFile;
|
||||||
|
pname = "lyt";
|
||||||
|
src = ./..;
|
||||||
|
main-package = pkgs.rustPlatform.buildRustPackage {
|
||||||
|
inherit pname src;
|
||||||
|
version = (fromTOML (readFile "${src}/${pname}/Cargo.toml")).package.version;
|
||||||
|
cargoHash = "sha256-ZrT35F8EoawLgJVcp15kBLGkQZkhi1dxkYEAsV1ZlaU=";
|
||||||
|
useFetchCargoVendor = true;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
${pname} = main-package;
|
||||||
|
default = main-package;
|
||||||
|
}
|
21
nix/shells.nix
Normal file
21
nix/shells.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (pkgs) system;
|
||||||
|
in {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
inherit (self.checks.${system}.git-hooks) shellHook;
|
||||||
|
inputsFrom = [self.packages.${system}.default];
|
||||||
|
packages = with pkgs; [
|
||||||
|
convco
|
||||||
|
rustPackages.clippy
|
||||||
|
typescript-language-server
|
||||||
|
rust-analyzer
|
||||||
|
rustfmt
|
||||||
|
nixd
|
||||||
|
lldb
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue