devenv + cleanup

This commit is contained in:
Lukas Wurzinger 2024-12-19 18:30:18 +01:00
parent d87895fa19
commit 1487c708c1
No known key found for this signature in database
6 changed files with 259 additions and 125 deletions

10
.envrc
View file

@ -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

14
devenv.nix Normal file
View file

@ -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;
};
}

19
disk/disk.nix Normal file
View file

@ -0,0 +1,19 @@
{
writeShellApplication,
util-linux,
jq,
e2fsprogs,
dosfstools,
}:
writeShellApplication {
name = "disk";
runtimeInputs = [
util-linux
jq
e2fsprogs
dosfstools
];
text = builtins.readFile ./disk.bash;
}

View file

@ -21,6 +21,34 @@
"type": "github" "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": { "darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -43,6 +71,40 @@
"type": "github" "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-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -76,6 +138,28 @@
} }
}, },
"flake-parts": { "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": { "inputs": {
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
@ -95,17 +179,24 @@
}, },
"git-hooks": { "git-hooks": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": [
"devenv"
],
"gitignore": "gitignore", "gitignore": "gitignore",
"nixpkgs": "nixpkgs_2", "nixpkgs": [
"nixpkgs-stable": "nixpkgs-stable" "devenv",
"nixpkgs"
],
"nixpkgs-stable": [
"devenv"
]
}, },
"locked": { "locked": {
"lastModified": 1734261738, "lastModified": 1730302582,
"narHash": "sha256-3Lzk+7QyX8v60+km26D3dln7NMSA13vW+KYTkMkds6Q=", "narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=",
"owner": "cachix", "owner": "cachix",
"repo": "git-hooks.nix", "repo": "git-hooks.nix",
"rev": "4c8e75efbbdcc6f9203f64b1f21f8a55d2285264", "rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -117,6 +208,7 @@
"gitignore": { "gitignore": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"devenv",
"git-hooks", "git-hooks",
"nixpkgs" "nixpkgs"
] ]
@ -137,11 +229,11 @@
}, },
"hardware": { "hardware": {
"locked": { "locked": {
"lastModified": 1733861262, "lastModified": 1734352517,
"narHash": "sha256-+jjPup/ByS0LEVIrBbt7FnGugJgLeG9oc+ivFASYn2U=", "narHash": "sha256-mfv+J/vO4nqmIOlq8Y1rRW8hVsGH3M+I2ESMjhuebDs=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"rev": "cf737e2eba82b603f54f71b10cb8fd09d22ce3f5", "rev": "b12e314726a4226298fe82776b4baeaa7bcf3dcd",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -173,14 +265,14 @@
}, },
"hxwrap": { "hxwrap": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_5"
}, },
"locked": { "locked": {
"lastModified": 1734165434, "lastModified": 1734510777,
"narHash": "sha256-IA0bfhXzusSXKmc4MYVozlkFXaJj2v7Z4A7IpM90GtI=", "narHash": "sha256-spRBSN62+Xf+2SQFIzSXn5kHYY401ujzBrC8ixz2CwE=",
"owner": "lukaswrz", "owner": "lukaswrz",
"repo": "hxwrap", "repo": "hxwrap",
"rev": "3247594e7bac7298fe541212aea8645f7727325d", "rev": "720e7770a2588c847e01df88f9a1a35e32601788",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -189,19 +281,68 @@
"type": "github" "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": { "nixos-cosmic": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_2",
"nixpkgs": "nixpkgs_4", "nixpkgs": "nixpkgs_6",
"nixpkgs-stable": "nixpkgs-stable_2", "nixpkgs-stable": "nixpkgs-stable",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1734227601, "lastModified": 1734404414,
"narHash": "sha256-H3lZV8A1cn2TopvJnjHmSLbzj12X9nlcVZuEWHHW+iE=", "narHash": "sha256-c/7bsbMcVMb8c4wiLA142ZQfL08U8qYJROGf9NCkfQE=",
"owner": "lilyinstarlight", "owner": "lilyinstarlight",
"repo": "nixos-cosmic", "repo": "nixos-cosmic",
"rev": "0a12841c81a192a6f76a51d9f07ad6bc22206cce", "rev": "a364e6a5e9eb93253daf93c747b150e31e09b13c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -239,22 +380,6 @@
} }
}, },
"nixpkgs-stable": { "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": { "locked": {
"lastModified": 1734083684, "lastModified": 1734083684,
"narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=", "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=",
@ -272,43 +397,59 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1730768919, "lastModified": 1730531603,
"narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=", "narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc", "rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixpkgs-unstable", "ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1733940404, "lastModified": 1717432640,
"narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", "narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", "rev": "88269ab3044128b7c2f4c7d68448b2fb50456870",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-unstable", "ref": "release-24.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs_4": { "nixpkgs_4": {
"locked": { "locked": {
"lastModified": 1733940404, "lastModified": 1716977621,
"narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", "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", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -318,18 +459,18 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_5": { "nixpkgs_6": {
"locked": { "locked": {
"lastModified": 1733097829, "lastModified": 1734119587,
"narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=", "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=",
"owner": "nixos", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a", "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "NixOS",
"ref": "nixpkgs-unstable", "ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -337,16 +478,16 @@
"root": { "root": {
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"flake-parts": "flake-parts", "devenv": "devenv",
"git-hooks": "git-hooks", "devenv-root": "devenv-root",
"flake-parts": "flake-parts_2",
"hardware": "hardware", "hardware": "hardware",
"hxwrap": "hxwrap", "hxwrap": "hxwrap",
"nixos-cosmic": "nixos-cosmic", "nixos-cosmic": "nixos-cosmic",
"nixpkgs": [ "nixpkgs": [
"nixos-cosmic", "nixos-cosmic",
"nixpkgs" "nixpkgs"
], ]
"treefmt": "treefmt"
} }
}, },
"rust-overlay": { "rust-overlay": {
@ -357,11 +498,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1734143514, "lastModified": 1734316514,
"narHash": "sha256-1+r8wYucn8kp9d/IBW1uYGs31QQmSZURElsiOTx65xM=", "narHash": "sha256-0aLx44yMblcOGpfFXKCzp2GhU5JaE6OTvdU+JYrXiUc=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "81fe5c27cb281a9b796d7ad05ad9179e5bd0c78d", "rev": "83ee8ff74d6294a7657320f16814754c4594127b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -384,24 +525,6 @@
"repo": "default", "repo": "default",
"type": "github" "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", "root": "root",

View file

@ -6,12 +6,6 @@
flake-parts.url = "github:hercules-ci/flake-parts"; 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 support
hardware.url = "github:NixOS/nixos-hardware"; hardware.url = "github:NixOS/nixos-hardware";
@ -24,19 +18,24 @@
# COSMIC # COSMIC
nixos-cosmic.url = "github:lilyinstarlight/nixos-cosmic"; nixos-cosmic.url = "github:lilyinstarlight/nixos-cosmic";
nixpkgs.follows = "nixos-cosmic/nixpkgs"; nixpkgs.follows = "nixos-cosmic/nixpkgs";
# Devenv
devenv-root = {
url = "file+file:///dev/null";
flake = false;
};
devenv.url = "github:cachix/devenv";
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
flake-parts, flake-parts,
treefmt,
... ...
} @ inputs: } @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} { flake-parts.lib.mkFlake {inherit inputs;} {
imports = [ imports = [
inputs.git-hooks.flakeModule inputs.devenv.flakeModule
inputs.treefmt.flakeModule
]; ];
systems = ["x86_64-linux" "aarch64-linux"]; systems = ["x86_64-linux" "aarch64-linux"];
@ -48,38 +47,20 @@
}; };
perSystem = { perSystem = {
config,
pkgs, pkgs,
inputs', 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 = { name = "puter";
check.enable = true;
settings = { imports = [
hooks = { ./devenv.nix
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
]; ];
packages = [ packages = [
@ -87,18 +68,7 @@
]; ];
}; };
packages.disk = pkgs.writeShellApplication { packages.disk = pkgs.callPackage ./disk {};
name = "disk";
runtimeInputs = with pkgs; [
util-linux
jq
e2fsprogs
dosfstools
];
text = builtins.readFile ./disk.bash;
};
}; };
}; };
} }