From 70b141fc8ad069b52880ddbd36dc80e643ccee1b Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Tue, 21 Apr 2026 09:14:32 +0100 Subject: [PATCH] chore: make flake simpler --- flake.lock | 113 ++++++++++++++-------------------------------------- flake.nix | 57 ++++++++------------------ src/main.rs | 1 - 3 files changed, 48 insertions(+), 123 deletions(-) diff --git a/flake.lock b/flake.lock index 3605e48..f24ba0a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,69 +1,17 @@ { "nodes": { - "advisory-db": { - "flake": false, - "locked": { - "lastModified": 1750151065, - "narHash": "sha256-il+CAqChFIB82xP6bO43dWlUVs+NlG7a4g8liIP5HcI=", - "owner": "rustsec", - "repo": "advisory-db", - "rev": "7573f55ba337263f61167dbb0ea926cdc7c8eb5d", - "type": "github" - }, - "original": { - "owner": "rustsec", - "repo": "advisory-db", - "type": "github" - } - }, - "crane": { - "locked": { - "lastModified": 1751562746, - "narHash": "sha256-smpugNIkmDeicNz301Ll1bD7nFOty97T79m4GUMUczA=", - "owner": "ipetkov", - "repo": "crane", - "rev": "aed2020fd3dc26e1e857d4107a5a67a33ab6c1fd", - "type": "github" - }, - "original": { - "owner": "ipetkov", - "repo": "crane", - "type": "github" - } - }, - "fenix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "rust-analyzer-src": "rust-analyzer-src" - }, - "locked": { - "lastModified": 1751870679, - "narHash": "sha256-aP4korVsN5Yy+PB9zjjm8Qbo3a69/m8vlFXS5mdVXtk=", - "owner": "nix-community", - "repo": "fenix", - "rev": "95606d64662a730da5d3031ed798dd6315d35f33", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "fenix", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", "type": "github" }, "original": { - "owner": "edolstra", + "owner": "NixOS", "repo": "flake-compat", "type": "github" } @@ -75,11 +23,11 @@ ] }, "locked": { - "lastModified": 1751413152, - "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", + "lastModified": 1775087534, + "narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", + "rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b", "type": "github" }, "original": { @@ -111,11 +59,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1751792365, - "narHash": "sha256-J1kI6oAj25IG4EdVlg2hQz8NZTBNYvIS0l4wpr9KcUo=", + "lastModified": 1776548001, + "narHash": "sha256-ZSK0NL4a1BwVbbTBoSnWgbJy9HeZFXLYQizjb2DPF24=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1fd8bada0b6117e6c7eb54aad5813023eed37ccb", + "rev": "b12141ef619e0a9c1c84dc8c684040326f27cdcc", "type": "github" }, "original": { @@ -134,11 +82,11 @@ ] }, "locked": { - "lastModified": 1750779888, - "narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=", + "lastModified": 1775585728, + "narHash": "sha256-8Psjt+TWvE4thRKktJsXfR6PA/fWWsZ04DVaY6PUhr4=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d", + "rev": "580633fa3fe5fc0379905986543fd7495481913d", "type": "github" }, "original": { @@ -149,30 +97,31 @@ }, "root": { "inputs": { - "advisory-db": "advisory-db", - "crane": "crane", - "fenix": "fenix", "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", "pre-commit-hooks": "pre-commit-hooks", + "rust-overlay": "rust-overlay", "systems": "systems", "treefmt-nix": "treefmt-nix" } }, - "rust-analyzer-src": { - "flake": false, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1751792916, - "narHash": "sha256-YjyurHKMrUYKjnujSqjpFtHGYFCGr2Xpo1Xc1AYT1+M=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "0ac65592a833bf40238831dd10e15283d63c46d5", + "lastModified": 1776741231, + "narHash": "sha256-k9G98qzn+7npROUaks8VqCFm7cFtEG8ulQLBBo5lItg=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "02061303f7c4c964f7b4584dabd9e985b4cd442b", "type": "github" }, "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", + "owner": "oxalica", + "repo": "rust-overlay", "type": "github" } }, @@ -198,11 +147,11 @@ ] }, "locked": { - "lastModified": 1750931469, - "narHash": "sha256-0IEdQB1nS+uViQw4k3VGUXntjkDp7aAlqcxdewb/hAc=", + "lastModified": 1775636079, + "narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "ac8e6f32e11e9c7f153823abc3ab007f2a65d3e1", + "rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 068eec0..a487b2d 100644 --- a/flake.nix +++ b/flake.nix @@ -5,15 +5,8 @@ flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; - fenix.inputs.nixpkgs.follows = "nixpkgs"; - fenix.url = "github:nix-community/fenix"; - - crane.url = "github:ipetkov/crane"; - - advisory-db = { - url = "github:rustsec/advisory-db"; - flake = false; - }; + rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; systems.url = "github:nix-systems/default"; @@ -27,7 +20,6 @@ }; outputs = { self, - nixpkgs, flake-parts, ... } @ inputs: @@ -41,51 +33,36 @@ perSystem = { pkgs, inputs', - self', config, ... }: let - rustToolchain = inputs'.fenix.packages.fromToolchainFile { - file = ./rust-toolchain.toml; - sha256 = "sha256-zC8E38iDVJ1oPIzCqTk/Ujo9+9kx9dXq7wAwPMpkpg0="; - }; - craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain; - src = craneLib.cleanCargoSource (craneLib.path ./.); - - nativeBuildInputs = with pkgs; [rustToolchain pkg-config]; - buildInputs = with pkgs; [udev]; - - commonArgs = { - inherit src buildInputs nativeBuildInputs; + rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + rustPlatform = pkgs.makeRustPlatform { + cargo = rustToolchain; + rustc = rustToolchain; }; - cargoArtifacts = craneLib.buildDepsOnly commonArgs; - bin = craneLib.buildPackage (commonArgs // {inherit cargoArtifacts;}); + bin = rustPlatform.buildRustPackage { + pname = "nish"; + version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version; + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + nativeBuildInputs = with pkgs; [pkg-config]; + buildInputs = with pkgs; [udev]; + }; in { - _module.args.pkgs = inputs'.nixpkgs.legacyPackages.extend inputs.fenix.overlays.default; + _module.args.pkgs = inputs'.nixpkgs.legacyPackages.extend inputs.rust-overlay.overlays.default; checks = { inherit bin; - clippy = craneLib.cargoClippy (commonArgs - // { - inherit cargoArtifacts; - cargoClippyExtraArgs = "--all-targets -- --deny warnings"; - }); - coverage = craneLib.cargoTarpaulin (commonArgs // {inherit cargoArtifacts;}); - fmt = craneLib.cargoFmt {inherit src;}; - audit = craneLib.cargoAudit { - inherit src; - inherit (inputs) advisory-db; - }; }; packages = { default = bin; }; - devShells.default = craneLib.devShell { - inherit (self') checks; + devShells.default = pkgs.mkShell { inputsFrom = [config.pre-commit.devShell config.treefmt.build.devShell]; - packages = []; + packages = [rustToolchain pkgs.pkg-config pkgs.udev]; }; pre-commit = { diff --git a/src/main.rs b/src/main.rs index 70ac147..2fa3613 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,6 @@ fn preprocess(s: &str) -> Result { async fn main() -> Result<(), runix::default::NixCommandLineRunError> { let cli = Args::parse(); std::env::set_var("NIXPKGS_ALLOW_UNFREE", "1"); - Shell { flake: FlakeArgs::default(), eval: EvaluationArgs {