diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..41917f6 --- /dev/null +++ b/default.nix @@ -0,0 +1,26 @@ +{ + pkgs, + inputs, + makeRustPlatform, + system, +}: let + toolchain = inputs.fenix.packages.${system}.minimal.toolchain; +in + (makeRustPlatform { + cargo = toolchain; + rustc = toolchain; + }) + .buildRustPackage { + pname = "forcebot_rs"; + version = "v1.0"; + + src = ./.; + cargoLock = { + lockFile = ./.; + }; + + nativeBuildInputs = with pkgs; [pkg-config]; + buildInputs = with pkgs; [openssl]; + + doCheck = false; + } diff --git a/flake.lock b/flake.lock index 9384f3e..f66c5b5 100644 --- a/flake.lock +++ b/flake.lock @@ -1,25 +1,5 @@ { "nodes": { - "crane": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1712513517, - "narHash": "sha256-VuLm5tTMqfS82NZAsNfsW7U+pTZ1+GcOU7gYR/Fb1Z4=", - "owner": "ipetkov", - "repo": "crane", - "rev": "9caad1eb0c69a13ee6467035353b71a76c85ea53", - "type": "github" - }, - "original": { - "owner": "ipetkov", - "repo": "crane", - "type": "github" - } - }, "fenix": { "inputs": { "nixpkgs": "nixpkgs", @@ -40,24 +20,6 @@ "type": "github" } }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1711703276, @@ -92,10 +54,9 @@ }, "root": { "inputs": { - "crane": "crane", "fenix": "fenix", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_2", + "systems": "systems" } }, "rust-analyzer-src": { @@ -117,16 +78,16 @@ }, "systems": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", "type": "github" }, "original": { "owner": "nix-systems", - "repo": "default", + "repo": "default-linux", "type": "github" } } diff --git a/flake.nix b/flake.nix index 6aec992..75414dc 100644 --- a/flake.nix +++ b/flake.nix @@ -1,53 +1,47 @@ { + description = "A basic flake"; + inputs = { + systems.url = "github:nix-systems/default-linux"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; fenix.url = "github:nix-community/fenix/monthly"; - - crane = { - url = "github:ipetkov/crane"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, + systems, nixpkgs, - crane, fenix, - flake-utils, - ... - } @ inputs: - flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { - inherit system overlays; - }; - - overlays = [fenix.overlays.default]; - - craneLib = crane.lib.${system}; - forcebot_rs = craneLib.buildPackage { - src = craneLib.cleanCargoSource (craneLib.path ./.); - strictDeps = true; - - nativeBuildInputs = [pkgs.pkg-config]; - buildInputs = [pkgs.openssl]; - }; + }: let + eachSystem = nixpkgs.lib.genAttrs (import systems); + pkgsFor = eachSystem (system: + import nixpkgs { + localSystem.system = system; + overlays = [fenix.overlays.default]; + }); + in { + packages = eachSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; in { - checks = { - inherit forcebot_rs; + default = pkgsFor.${system}.rustPlatform.buildRustPackage { + pname = "forcebot_rs"; + version = "v0.1"; + + src = self; + + cargoLock = { + lockFile = ./Cargo.lock; + }; + + nativeBuildInputs = with pkgs; [pkg-config]; + buildInputs = with pkgs; [openssl]; + + doCheck = false; }; - - packages.default = forcebot_rs; - - apps.default = flake-utils.lib.mkApp { - drv = forcebot_rs; - }; - - devShells.default = craneLib.devShell { - checks = self.checks.${system}; - packages = with pkgs; [ + }); + devShells = eachSystem (system: { + default = pkgsFor.${system}.mkShell { + packages = with pkgsFor.${system}; [ nil alejandra rust-analyzer-nightly @@ -60,14 +54,7 @@ ]) ]; }; - nixosModules.forcebot_rs = import ./nix/module.nix; - nixosModules.default = self.nixosModules.forcebot_rs; - RUST_BACKTRACE = 1; - RUST_SRC_PATH = "${fenix.packages.${system}.complete.rust-src}/lib/rustlib/src/rust/library"; - }) - // { - overlays.default = final: prev: { - forcebot_rs = self.packages."${final.system}".default; - }; - }; + }); + nixosModules.default = import ./nix/module.nix; + }; }