fix flake builds

This commit is contained in:
Akshay 2021-10-19 20:39:11 +05:30
parent e4c4a77d03
commit a1886854d9
3 changed files with 99 additions and 107 deletions

View File

@ -16,6 +16,21 @@
"type": "github" "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"
}
},
"mozillapkgs": { "mozillapkgs": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -32,74 +47,28 @@
"type": "github" "type": "github"
} }
}, },
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1631004250,
"narHash": "sha256-LGh0CjAZwh13AVkTi9w9lITEC7x6bwSQyFViOZ6HyNo=",
"owner": "nmattia",
"repo": "naersk",
"rev": "08afb3d1dbfe016108b72e05b02ba0f6ecb3c8e1",
"type": "github"
},
"original": {
"owner": "nmattia",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1631279684, "lastModified": 1633422745,
"narHash": "sha256-IxRRCEW+8crDkbYj+uzwkfjZ8swugtnAmfRpPOpKq6I=", "narHash": "sha256-gA6Ok64nPbkjHk3Oanq4641EeYkjcKhisDF9wBjLxEk=",
"owner": "NixOS", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "ded7b6cb1bf3d6d03328b3f592069f2c4956a97f", "rev": "8e1eab9eae4278c9bb1dcae426848a581943db5a",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "owner": "nixos",
"type": "indirect" "ref": "nixpkgs-unstable",
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1631279684,
"narHash": "sha256-IxRRCEW+8crDkbYj+uzwkfjZ8swugtnAmfRpPOpKq6I=",
"owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "ded7b6cb1bf3d6d03328b3f592069f2c4956a97f",
"type": "github" "type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"import-cargo": "import-cargo",
"mozillapkgs": "mozillapkgs", "mozillapkgs": "mozillapkgs",
"naersk": "naersk", "nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs_2",
"utils": "utils"
}
},
"utils": {
"locked": {
"lastModified": 1629481132,
"narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "997f7efcb746a9c140ce1f13c72263189225f482",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
} }
} }
}, },

128
flake.nix
View File

@ -1,80 +1,102 @@
{ {
inputs = { inputs = {
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nmattia/naersk"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
mozillapkgs = { mozillapkgs = {
url = "github:mozilla/nixpkgs-mozilla"; url = "github:mozilla/nixpkgs-mozilla";
flake = false; flake = false;
}; };
flake-compat = { flake-compat = {
url = "github:edolstra/flake-compat"; url = "github:edolstra/flake-compat";
flake = false; flake = false;
}; };
import-cargo.url = github:edolstra/import-cargo;
}; };
outputs = outputs =
{ self { self
, nixpkgs , nixpkgs
, utils
, naersk
, mozillapkgs , mozillapkgs
, import-cargo
, ... , ...
}: }:
utils.lib.eachDefaultSystem (system:
let let
pkgs = nixpkgs.legacyPackages."${system}"; inherit (import-cargo.builders) importCargo;
supportedSystems = [ "x86_64-linux" ];
# Get a specific rust version forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
mozilla = pkgs.callPackage (mozillapkgs + "/package-set.nix") { }; nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
});
mozilla = p: p.callPackage (mozillapkgs + "/package-set.nix") { };
chanspec = { chanspec = {
date = "2021-03-31"; date = "2021-09-30";
channel = "nightly"; channel = "nightly";
sha256 = "oK5ebje09MRn988saJMT3Zze/tRE7u9zTeFPV1CEeLc="; # set zeros after modifying channel or date sha256 = "Elqn7GDBDE/QT1XTDyj0EvivbC//uwjWX8d+J3Pi0dY="; # set zeros after modifying channel or date
}; };
rustChannel = mozilla.rustChannelOf chanspec;
rust = rustChannel.rust;
rust-src = rustChannel.rust-src;
naersk-lib = naersk.lib."${system}".override {
cargo = rust;
rustc = rust;
};
nativeBuildInputs = with pkgs; [ ];
in in
rec { {
packages.statix = naersk-lib.buildPackage {
pname = "statix";
version = "0.1.0";
root = ./.;
inherit nativeBuildInputs;
};
defaultPackage = packages.statix; overlay = final: prev:
apps.statix = utils.lib.mkApp { let
drv = packages.statix; rustChannel = (mozilla final.pkgs).rustChannelOf chanspec;
}; inherit (rustChannel) rust rustc rust-src;
in
{
apps.check = { statix = with final; pkgs.stdenv.mkDerivation {
type = "app"; pname = "statix";
program = "${pkgs.cargo-watch}/bin/cargo-watch"; version = "v0.1.0";
}; src = ./.;
nativeBuildInputs = [
(importCargo { lockFile = ./Cargo.lock; inherit pkgs; }).cargoHome
rust
cargo
];
buildPhase = ''
cargo build -p statix --release --offline
'';
installPhase = ''
install -Dm775 ./target/release/statix $out/bin/statix
'';
};
defaultApp = apps.statix; };
devShell = pkgs.mkShell {
nativeBuildInputs = nativeBuildInputs ++ [ packages = forAllSystems (system: {
rust inherit (nixpkgsFor."${system}") statix;
rust-src });
pkgs.rust-analyzer
pkgs.rustfmt defaultPackage =
pkgs.cargo forAllSystems (system: self.packages."${system}".statix);
pkgs.cargo-watch
]; devShell = forAllSystems (system:
RUST_SRC_PATH = "${rust-src}/lib/rustlib/src/rust/library"; let
RUST_LOG = "info"; pkgs = nixpkgsFor.${system};
RUST_BACKTRACE = 1; rustChannel = (mozilla pkgs).rustChannelOf chanspec;
}; in
}); with pkgs;
mkShell rec {
buildInputs =
(with pkgs; [
rust-analyzer
rustfmt
cargo
cargo-watch
]) ++ (with rustChannel; [
rust
rust-src
]);
RUST_SRC_PATH = "${rustChannel.rust-src}/lib/rustlib/src/rust/library";
RUST_LOG = "info";
RUST_BACKTRACE = 1;
});
};
} }

View File

@ -8,6 +8,7 @@ Interface
- load files to be read as VFS - load files to be read as VFS
- path interner - path interner
- traits to go from Report to text/errfmt - traits to go from Report to text/errfmt
- offline documentation/explaination for lints
Fix Fix
--- ---