diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4dcfa87 --- /dev/null +++ b/flake.lock @@ -0,0 +1,77 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1709126324, + "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "d465f4819400de7c8d874d50b982301f28a84605", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "import-cargo": { + "locked": { + "lastModified": 1594305518, + "narHash": "sha256-frtArgN42rSaEcEOYWg8sVPMUK+Zgch3c+wejcpX3DY=", + "owner": "edolstra", + "repo": "import-cargo", + "rev": "25d40be4a73d40a2572e0cc233b83253554f06c5", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "import-cargo", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1709237383, + "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "import-cargo": "import-cargo", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7f20021 --- /dev/null +++ b/flake.nix @@ -0,0 +1,42 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + import-cargo.url = "github:edolstra/import-cargo"; + }; + + outputs = { self, nixpkgs, flake-utils, import-cargo }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + inherit (import-cargo.builders) importCargo; + in { + packages.default = pkgs.stdenv.mkDerivation { + name = "trvcontrol"; + src = self; + + nativeBuildInputs = with pkgs; [ + # setupHook which makes sure that a CARGO_HOME with vendored dependencies + # exists + (importCargo { + lockFile = ./Cargo.lock; + inherit pkgs; + }).cargoHome + + # Build-time dependencies + rustc + cargo + ]; + + buildPhase = '' + cargo build --release --offline + ''; + + installPhase = '' + install -Dm775 ./target/release/trvcontrol $out/bin/trvcontrol + ''; + + }; + + }); +}