diff --git a/.envrc b/.envrc index 3550a30..cb982f0 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,9 @@ -use flake +watch_file flake.nix +watch_file flake.lock + +DEVENV_ROOT_FILE="$(mktemp)" +printf %s "$PWD" > "$DEVENV_ROOT_FILE" +if ! use flake . --override-input devenv-root "file+file://$DEVENV_ROOT_FILE" +then + echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 +fi diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..67c93b5 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,14 @@ +{ + pre-commit.hooks = { + # Nix + alejandra.enable = true; + deadnix.enable = true; + statix.enable = true; + + # Flakes + flake-checker.enable = true; + + # Shell + shellcheck.enable = true; + }; +} diff --git a/disk.bash b/disk/disk.bash similarity index 100% rename from disk.bash rename to disk/disk.bash diff --git a/disk/disk.nix b/disk/disk.nix new file mode 100644 index 0000000..0d292c1 --- /dev/null +++ b/disk/disk.nix @@ -0,0 +1,19 @@ +{ + writeShellApplication, + util-linux, + jq, + e2fsprogs, + dosfstools, +}: +writeShellApplication { + name = "disk"; + + runtimeInputs = [ + util-linux + jq + e2fsprogs + dosfstools + ]; + + text = builtins.readFile ./disk.bash; +} diff --git a/flake.lock b/flake.lock index 91b075c..e7d0d52 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,34 @@ "type": "github" } }, + "cachix": { + "inputs": { + "devenv": [ + "devenv" + ], + "flake-compat": [ + "devenv" + ], + "git-hooks": [ + "devenv" + ], + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1728672398, + "narHash": "sha256-KxuGSoVUFnQLB2ZcYODW7AVPAh9JqRlD5BrfsC/Q4qs=", + "owner": "cachix", + "repo": "cachix", + "rev": "aac51f698309fd0f381149214b7eee213c66ef0a", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "latest", + "repo": "cachix", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -43,6 +71,40 @@ "type": "github" } }, + "devenv": { + "inputs": { + "cachix": "cachix", + "flake-compat": "flake-compat", + "git-hooks": "git-hooks", + "nix": "nix", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1734441494, + "narHash": "sha256-/SZXjdKlo6NgVR+/RT0eYCUUJLcQndy7lIl2Bc0qjlY=", + "owner": "cachix", + "repo": "devenv", + "rev": "bdc1a2cefdda8f89e31b1a0f3771786ba9e5d052", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "devenv-root": { + "flake": false, + "locked": { + "narHash": "sha256-d6xi4mKdjkX2JFicDIv5niSzpyI0m/Hnm8GGAIU04kY=", + "type": "file", + "url": "file:///dev/null" + }, + "original": { + "type": "file", + "url": "file:///dev/null" + } + }, "flake-compat": { "flake": false, "locked": { @@ -76,6 +138,28 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "devenv", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, @@ -95,17 +179,24 @@ }, "git-hooks": { "inputs": { - "flake-compat": "flake-compat", + "flake-compat": [ + "devenv" + ], "gitignore": "gitignore", - "nixpkgs": "nixpkgs_2", - "nixpkgs-stable": "nixpkgs-stable" + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-stable": [ + "devenv" + ] }, "locked": { - "lastModified": 1734261738, - "narHash": "sha256-3Lzk+7QyX8v60+km26D3dln7NMSA13vW+KYTkMkds6Q=", + "lastModified": 1730302582, + "narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "4c8e75efbbdcc6f9203f64b1f21f8a55d2285264", + "rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf", "type": "github" }, "original": { @@ -117,6 +208,7 @@ "gitignore": { "inputs": { "nixpkgs": [ + "devenv", "git-hooks", "nixpkgs" ] @@ -137,11 +229,11 @@ }, "hardware": { "locked": { - "lastModified": 1733861262, - "narHash": "sha256-+jjPup/ByS0LEVIrBbt7FnGugJgLeG9oc+ivFASYn2U=", + "lastModified": 1734352517, + "narHash": "sha256-mfv+J/vO4nqmIOlq8Y1rRW8hVsGH3M+I2ESMjhuebDs=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "cf737e2eba82b603f54f71b10cb8fd09d22ce3f5", + "rev": "b12e314726a4226298fe82776b4baeaa7bcf3dcd", "type": "github" }, "original": { @@ -173,14 +265,14 @@ }, "hxwrap": { "inputs": { - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1734165434, - "narHash": "sha256-IA0bfhXzusSXKmc4MYVozlkFXaJj2v7Z4A7IpM90GtI=", + "lastModified": 1734510777, + "narHash": "sha256-spRBSN62+Xf+2SQFIzSXn5kHYY401ujzBrC8ixz2CwE=", "owner": "lukaswrz", "repo": "hxwrap", - "rev": "3247594e7bac7298fe541212aea8645f7727325d", + "rev": "720e7770a2588c847e01df88f9a1a35e32601788", "type": "github" }, "original": { @@ -189,19 +281,68 @@ "type": "github" } }, + "libgit2": { + "flake": false, + "locked": { + "lastModified": 1697646580, + "narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=", + "owner": "libgit2", + "repo": "libgit2", + "rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5", + "type": "github" + }, + "original": { + "owner": "libgit2", + "repo": "libgit2", + "type": "github" + } + }, + "nix": { + "inputs": { + "flake-compat": [ + "devenv" + ], + "flake-parts": "flake-parts", + "libgit2": "libgit2", + "nixpkgs": "nixpkgs_3", + "nixpkgs-23-11": [ + "devenv" + ], + "nixpkgs-regression": [ + "devenv" + ], + "pre-commit-hooks": [ + "devenv" + ] + }, + "locked": { + "lastModified": 1727438425, + "narHash": "sha256-X8ES7I1cfNhR9oKp06F6ir4Np70WGZU5sfCOuNBEwMg=", + "owner": "domenkozar", + "repo": "nix", + "rev": "f6c5ae4c1b2e411e6b1e6a8181cc84363d6a7546", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.24", + "repo": "nix", + "type": "github" + } + }, "nixos-cosmic": { "inputs": { "flake-compat": "flake-compat_2", - "nixpkgs": "nixpkgs_4", - "nixpkgs-stable": "nixpkgs-stable_2", + "nixpkgs": "nixpkgs_6", + "nixpkgs-stable": "nixpkgs-stable", "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1734227601, - "narHash": "sha256-H3lZV8A1cn2TopvJnjHmSLbzj12X9nlcVZuEWHHW+iE=", + "lastModified": 1734404414, + "narHash": "sha256-c/7bsbMcVMb8c4wiLA142ZQfL08U8qYJROGf9NCkfQE=", "owner": "lilyinstarlight", "repo": "nixos-cosmic", - "rev": "0a12841c81a192a6f76a51d9f07ad6bc22206cce", + "rev": "a364e6a5e9eb93253daf93c747b150e31e09b13c", "type": "github" }, "original": { @@ -239,22 +380,6 @@ } }, "nixpkgs-stable": { - "locked": { - "lastModified": 1730741070, - "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d063c1dd113c91ab27959ba540c0d9753409edf3", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-24.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-stable_2": { "locked": { "lastModified": 1734083684, "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=", @@ -272,43 +397,59 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1730768919, - "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=", + "lastModified": 1730531603, + "narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc", + "rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_3": { "locked": { - "lastModified": 1733940404, - "narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", + "lastModified": 1717432640, + "narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", + "rev": "88269ab3044128b7c2f4c7d68448b2fb50456870", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "release-24.05", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_4": { "locked": { - "lastModified": 1733940404, - "narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", + "lastModified": 1716977621, + "narHash": "sha256-Q1UQzYcMJH4RscmpTkjlgqQDX5yi1tZL0O345Ri6vXQ=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1734119587, + "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", "type": "github" }, "original": { @@ -318,18 +459,18 @@ "type": "github" } }, - "nixpkgs_5": { + "nixpkgs_6": { "locked": { - "lastModified": 1733097829, - "narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=", - "owner": "nixos", + "lastModified": 1734119587, + "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", + "owner": "NixOS", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } @@ -337,16 +478,16 @@ "root": { "inputs": { "agenix": "agenix", - "flake-parts": "flake-parts", - "git-hooks": "git-hooks", + "devenv": "devenv", + "devenv-root": "devenv-root", + "flake-parts": "flake-parts_2", "hardware": "hardware", "hxwrap": "hxwrap", "nixos-cosmic": "nixos-cosmic", "nixpkgs": [ "nixos-cosmic", "nixpkgs" - ], - "treefmt": "treefmt" + ] } }, "rust-overlay": { @@ -357,11 +498,11 @@ ] }, "locked": { - "lastModified": 1734143514, - "narHash": "sha256-1+r8wYucn8kp9d/IBW1uYGs31QQmSZURElsiOTx65xM=", + "lastModified": 1734316514, + "narHash": "sha256-0aLx44yMblcOGpfFXKCzp2GhU5JaE6OTvdU+JYrXiUc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "81fe5c27cb281a9b796d7ad05ad9179e5bd0c78d", + "rev": "83ee8ff74d6294a7657320f16814754c4594127b", "type": "github" }, "original": { @@ -384,24 +525,6 @@ "repo": "default", "type": "github" } - }, - "treefmt": { - "inputs": { - "nixpkgs": "nixpkgs_5" - }, - "locked": { - "lastModified": 1733761991, - "narHash": "sha256-s4DalCDepD22jtKL5Nw6f4LP5UwoMcPzPZgHWjAfqbQ=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "0ce9d149d99bc383d1f2d85f31f6ebd146e46085", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index fd58c74..a778d5f 100644 --- a/flake.nix +++ b/flake.nix @@ -6,12 +6,6 @@ flake-parts.url = "github:hercules-ci/flake-parts"; - # Pre-commit - git-hooks.url = "github:cachix/git-hooks.nix"; - - # Formatting - treefmt.url = "github:numtide/treefmt-nix"; - # Hardware support hardware.url = "github:NixOS/nixos-hardware"; @@ -24,19 +18,24 @@ # COSMIC nixos-cosmic.url = "github:lilyinstarlight/nixos-cosmic"; nixpkgs.follows = "nixos-cosmic/nixpkgs"; + + # Devenv + devenv-root = { + url = "file+file:///dev/null"; + flake = false; + }; + devenv.url = "github:cachix/devenv"; }; outputs = { self, nixpkgs, flake-parts, - treefmt, ... } @ inputs: flake-parts.lib.mkFlake {inherit inputs;} { imports = [ - inputs.git-hooks.flakeModule - inputs.treefmt.flakeModule + inputs.devenv.flakeModule ]; systems = ["x86_64-linux" "aarch64-linux"]; @@ -48,38 +47,20 @@ }; perSystem = { - config, pkgs, inputs', ... }: { - treefmt = ./treefmt.nix; + devenv.shells.default = { + devenv.root = let + devenvRootFileContent = builtins.readFile inputs.devenv-root.outPath; + in + pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent; - pre-commit = { - check.enable = true; + name = "puter"; - settings = { - hooks = { - treefmt.enable = true; - deadnix.enable = true; - statix.enable = true; - shellcheck = { - enable = true; - excludes = [ - "^\.envrc$" - ]; - }; - flake-checker.enable = true; - }; - }; - }; - - devShells.default = pkgs.mkShellNoCC { - inherit (config.pre-commit.devShell) shellHook; - - inputsFrom = [ - config.pre-commit.devShell - config.treefmt.build.devShell + imports = [ + ./devenv.nix ]; packages = [ @@ -87,18 +68,7 @@ ]; }; - packages.disk = pkgs.writeShellApplication { - name = "disk"; - - runtimeInputs = with pkgs; [ - util-linux - jq - e2fsprogs - dosfstools - ]; - - text = builtins.readFile ./disk.bash; - }; + packages.disk = pkgs.callPackage ./disk {}; }; }; }