2022-09-02 23:03:57 +00:00
|
|
|
{
|
2022-12-19 18:26:58 +00:00
|
|
|
description = "A Nix Installer";
|
2022-09-02 23:03:57 +00:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
|
|
|
|
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
naersk = {
|
|
|
|
url = "github:nix-community/naersk";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
{ self
|
|
|
|
, nixpkgs
|
|
|
|
, fenix
|
|
|
|
, naersk
|
|
|
|
, ...
|
|
|
|
} @ inputs:
|
|
|
|
let
|
2022-12-16 18:32:30 +00:00
|
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2022-09-02 23:03:57 +00:00
|
|
|
|
2022-12-16 18:32:30 +00:00
|
|
|
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
|
2022-09-02 23:03:57 +00:00
|
|
|
inherit system;
|
2022-12-16 18:32:30 +00:00
|
|
|
pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; };
|
2022-09-02 23:03:57 +00:00
|
|
|
lib = pkgs.lib;
|
|
|
|
});
|
|
|
|
|
|
|
|
fenixToolchain = system: with fenix.packages.${system};
|
|
|
|
combine ([
|
|
|
|
stable.clippy
|
|
|
|
stable.rustc
|
|
|
|
stable.cargo
|
|
|
|
stable.rustfmt
|
|
|
|
stable.rust-src
|
|
|
|
] ++ nixpkgs.lib.optionals (system == "x86_64-linux") [
|
|
|
|
targets.x86_64-unknown-linux-musl.stable.rust-std
|
|
|
|
] ++ nixpkgs.lib.optionals (system == "aarch64-linux") [
|
|
|
|
targets.aarch64-unknown-linux-musl.stable.rust-std
|
|
|
|
]);
|
|
|
|
in
|
|
|
|
{
|
2022-12-16 18:32:30 +00:00
|
|
|
overlays.default = final: prev:
|
|
|
|
let
|
|
|
|
toolchain = fenixToolchain final.hostPlatform.system;
|
|
|
|
naerskLib = final.callPackage naersk {
|
|
|
|
cargo = toolchain;
|
|
|
|
rustc = toolchain;
|
|
|
|
};
|
|
|
|
sharedAttrs = {
|
2022-12-19 18:26:58 +00:00
|
|
|
pname = "nix-installer";
|
2022-12-16 18:32:30 +00:00
|
|
|
version = "0.0.0-unreleased";
|
|
|
|
src = self;
|
|
|
|
|
|
|
|
nativeBuildInputs = with final; [ ];
|
|
|
|
buildInputs = with final; [ ] ++ lib.optionals (final.stdenv.isDarwin) (with final.darwin.apple_sdk.frameworks; [
|
|
|
|
SystemConfiguration
|
|
|
|
]);
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
doDoc = true;
|
|
|
|
doDocFail = true;
|
|
|
|
RUSTFLAGS = "--cfg tokio_unstable";
|
|
|
|
cargoTestOptions = f: f ++ [ "--all" ];
|
|
|
|
|
|
|
|
override = { preBuild ? "", ... }: {
|
|
|
|
preBuild = preBuild + ''
|
|
|
|
# logRun "cargo clippy --all-targets --all-features -- -D warnings"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
postInstall = ''
|
2022-12-19 18:26:58 +00:00
|
|
|
cp nix-installer.sh $out/bin/nix-installer.sh
|
2022-12-16 18:32:30 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
rec {
|
2022-12-19 18:26:58 +00:00
|
|
|
nix-installer = naerskLib.buildPackage sharedAttrs;
|
2022-12-16 18:32:30 +00:00
|
|
|
} // nixpkgs.lib.optionalAttrs (prev.hostPlatform.system == "x86_64-linux") rec {
|
2022-12-19 18:26:58 +00:00
|
|
|
default = nix-installer-static;
|
|
|
|
nix-installer-static = naerskLib.buildPackage
|
2022-12-16 18:32:30 +00:00
|
|
|
(sharedAttrs // {
|
|
|
|
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
|
|
|
|
});
|
|
|
|
} // nixpkgs.lib.optionalAttrs (prev.hostPlatform.system == "aarch64-linux") rec {
|
2022-12-19 18:26:58 +00:00
|
|
|
default = nix-installer-static;
|
|
|
|
nix-installer-static = naerskLib.buildPackage
|
2022-12-16 18:32:30 +00:00
|
|
|
(sharedAttrs // {
|
|
|
|
CARGO_BUILD_TARGET = "aarch64-unknown-linux-musl";
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-09-28 20:49:07 +00:00
|
|
|
devShells = forAllSystems ({ system, pkgs, ... }:
|
2022-09-02 23:03:57 +00:00
|
|
|
let
|
|
|
|
toolchain = fenixToolchain system;
|
|
|
|
eclint = import ./nix/eclint.nix { inherit pkgs; };
|
2022-12-05 18:27:12 +00:00
|
|
|
check = import ./nix/check.nix { inherit pkgs eclint toolchain; };
|
2022-09-02 23:03:57 +00:00
|
|
|
in
|
2022-09-28 20:49:07 +00:00
|
|
|
{
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
name = "nix-install-shell";
|
|
|
|
|
|
|
|
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
|
|
|
|
|
2022-12-12 16:18:29 +00:00
|
|
|
nativeBuildInputs = with pkgs; [ ];
|
2022-09-28 20:49:07 +00:00
|
|
|
buildInputs = with pkgs; [
|
|
|
|
toolchain
|
|
|
|
rust-analyzer
|
2022-11-01 16:32:14 +00:00
|
|
|
cargo-outdated
|
2022-09-28 20:49:07 +00:00
|
|
|
nixpkgs-fmt
|
2022-12-05 18:27:12 +00:00
|
|
|
check.check-rustfmt
|
|
|
|
check.check-spelling
|
|
|
|
check.check-nixpkgs-fmt
|
|
|
|
check.check-editorconfig
|
2022-09-28 20:49:07 +00:00
|
|
|
]
|
2022-12-12 16:18:29 +00:00
|
|
|
++ lib.optionals (pkgs.stdenv.isDarwin) (with pkgs; [ libiconv ]);
|
2022-09-28 20:49:07 +00:00
|
|
|
};
|
2022-09-02 23:03:57 +00:00
|
|
|
});
|
|
|
|
|
2022-10-13 16:11:23 +00:00
|
|
|
checks = forAllSystems ({ system, pkgs, ... }:
|
|
|
|
let
|
2022-12-05 18:27:12 +00:00
|
|
|
toolchain = fenixToolchain system;
|
|
|
|
eclint = import ./nix/eclint.nix { inherit pkgs; };
|
|
|
|
check = import ./nix/check.nix { inherit pkgs eclint toolchain; };
|
2022-10-13 16:11:23 +00:00
|
|
|
in
|
|
|
|
{
|
2022-12-05 18:27:12 +00:00
|
|
|
check-rustfmt = pkgs.runCommand "check-rustfmt" { buildInputs = [ check.check-rustfmt ]; } ''
|
|
|
|
cd ${./.}
|
|
|
|
check-rustfmt
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
check-spelling = pkgs.runCommand "check-spelling" { buildInputs = [ check.check-spelling ]; } ''
|
|
|
|
cd ${./.}
|
|
|
|
check-spelling
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
check-nixpkgs-fmt = pkgs.runCommand "check-nixpkgs-fmt" { buildInputs = [ check.check-nixpkgs-fmt ]; } ''
|
|
|
|
cd ${./.}
|
|
|
|
check-nixpkgs-fmt
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
check-editorconfig = pkgs.runCommand "check-editorconfig" { buildInputs = [ pkgs.git check.check-editorconfig ]; } ''
|
|
|
|
cd ${./.}
|
|
|
|
check-editorconfig
|
|
|
|
touch $out
|
2022-10-13 16:11:23 +00:00
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2022-12-16 18:32:30 +00:00
|
|
|
packages = forAllSystems ({ system, pkgs, ... }:
|
|
|
|
{
|
2022-12-19 18:26:58 +00:00
|
|
|
inherit (pkgs) nix-installer;
|
2022-12-16 18:32:30 +00:00
|
|
|
} // nixpkgs.lib.optionalAttrs (system == "x86_64-linux") {
|
2022-12-19 18:26:58 +00:00
|
|
|
inherit (pkgs) nix-installer-static;
|
|
|
|
default = pkgs.nix-installer-static;
|
2022-12-16 18:32:30 +00:00
|
|
|
} // nixpkgs.lib.optionalAttrs (system == "aarch64-linux") {
|
2022-12-19 18:26:58 +00:00
|
|
|
inherit (pkgs) nix-installer-static;
|
|
|
|
default = pkgs.nix-installer-static;
|
2022-12-16 18:32:30 +00:00
|
|
|
} // nixpkgs.lib.optionalAttrs (pkgs.stdenv.isDarwin) {
|
2022-12-19 18:26:58 +00:00
|
|
|
default = pkgs.nix-installer;
|
2022-12-16 18:32:30 +00:00
|
|
|
});
|
2022-09-02 23:03:57 +00:00
|
|
|
};
|
|
|
|
}
|