forAllSystems
This commit is contained in:
parent
419b29a49d
commit
f5fc5867d3
51
_flake.nix
51
_flake.nix
|
@ -1,51 +0,0 @@
|
||||||
# Tests run by 'nix flake check' and by Hydra.
|
|
||||||
checks = forAllSystems
|
|
||||||
(system:
|
|
||||||
with pkgs.${system};
|
|
||||||
|
|
||||||
{
|
|
||||||
inherit (self.packages.${system}) hello;
|
|
||||||
|
|
||||||
# Additional tests, if applicable.
|
|
||||||
test = stdenv.mkDerivation {
|
|
||||||
pname = "hello-test";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
buildInputs = [ hello ];
|
|
||||||
|
|
||||||
dontUnpack = true;
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
echo 'running some integration tests'
|
|
||||||
[[ $(hello) = 'Hello Nixers!' ]]
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = "mkdir -p $out";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// lib.optionalAttrs stdenv.isLinux {
|
|
||||||
# A VM test of the NixOS module.
|
|
||||||
vmTest =
|
|
||||||
with import (nixpkgs + "/nixos/lib/testing-python.nix") {
|
|
||||||
inherit system;
|
|
||||||
};
|
|
||||||
|
|
||||||
makeTest {
|
|
||||||
nodes = {
|
|
||||||
client = { ... }: {
|
|
||||||
imports = [ self.nixosModules.hello ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
testScript =
|
|
||||||
''
|
|
||||||
start_all()
|
|
||||||
client.wait_for_unit("multi-user.target")
|
|
||||||
client.succeed("hello")
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
84
flake.lock
84
flake.lock
|
@ -1,5 +1,50 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"alejandra": {
|
||||||
|
"inputs": {
|
||||||
|
"fenix": "fenix",
|
||||||
|
"flakeCompat": "flakeCompat",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1660510326,
|
||||||
|
"narHash": "sha256-xFumnivtVwu5fFBOrTxrv6fv3geHKF04RGP23EsDVaI=",
|
||||||
|
"owner": "kamadorueda",
|
||||||
|
"repo": "alejandra",
|
||||||
|
"rev": "ef03f7ef74ec97fd91a016a51c9c9667fb315652",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "kamadorueda",
|
||||||
|
"ref": "3.0.0",
|
||||||
|
"repo": "alejandra",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fenix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"alejandra",
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1657607339,
|
||||||
|
"narHash": "sha256-HaqoAwlbVVZH2n4P3jN2FFPMpVuhxDy1poNOR7kzODc=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"rev": "b814c83d9e6aa5a28d0cf356ecfdafb2505ad37d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -29,9 +74,8 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"id": "flake-utils",
|
||||||
"repo": "flake-utils",
|
"type": "indirect"
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils_2": {
|
"flake-utils_2": {
|
||||||
|
@ -67,6 +111,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flakeCompat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1650374568,
|
||||||
|
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"gitignore": {
|
"gitignore": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
@ -226,6 +286,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"alejandra": "alejandra",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nix-github-actions": "nix-github-actions",
|
"nix-github-actions": "nix-github-actions",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
|
@ -233,6 +294,23 @@
|
||||||
"zicross": "zicross"
|
"zicross": "zicross"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"rust-analyzer-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1657557289,
|
||||||
|
"narHash": "sha256-PRW+nUwuqNTRAEa83SfX+7g+g8nQ+2MMbasQ9nt6+UM=",
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"rev": "caf23f29144b371035b864a1017dbc32573ad56d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"ref": "nightly",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1681028828,
|
||||||
|
|
97
flake.nix
97
flake.nix
|
@ -7,15 +7,23 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs";
|
nixpkgs.url = "github:nixos/nixpkgs";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
zicross.url = "github:flyx/Zicross";
|
zicross.url = "github:flyx/Zicross";
|
||||||
|
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
|
||||||
|
nix-github-actions.url = "github:nix-community/nix-github-actions";
|
||||||
|
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
alejandra.url = "github:kamadorueda/alejandra/3.0.0";
|
||||||
|
alejandra.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
|
|
||||||
inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
|
|
||||||
inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks, nix-github-actions, zicross }:
|
outputs = {
|
||||||
let
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
pre-commit-hooks,
|
||||||
|
nix-github-actions,
|
||||||
|
alejandra,
|
||||||
|
zicross,
|
||||||
|
}: let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
officialRelease = false;
|
officialRelease = false;
|
||||||
|
|
||||||
|
@ -25,32 +33,34 @@
|
||||||
then ""
|
then ""
|
||||||
else "pre${builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}_${self.shortRev or "dirty"}";
|
else "pre${builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}_${self.shortRev or "dirty"}";
|
||||||
|
|
||||||
#supportedSystems = [ "i386-linux" "x86_64-linux" "armv6l-linux" "armv7l-linux" "aarch64-linux" "powerpc64le-linux" "riscv64-linux" "x86_64-darwin" "aarch64-darwin" "x86_64-windows" "x86_64-windows" ];
|
|
||||||
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
|
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
|
||||||
|
# ??? [ "i386-linux" "x86_64-linux" "armv6l-linux" "armv7l-linux" "aarch64-linux" "powerpc64le-linux" "riscv64-linux" "x86_64-darwin" "aarch64-darwin" "x86_64-windows" "x86_64-windows" ];
|
||||||
|
|
||||||
# Generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
# Generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
||||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
|
|
||||||
# Nixpkgs instantiated for supported system types.
|
# Nixpkgs instantiated for supported system types.
|
||||||
nixpkgsFor = forAllSystems (system: import nixpkgs {
|
nixpkgsFor = forAllSystems (system:
|
||||||
|
import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [ self.overlay ];
|
overlays =
|
||||||
|
[
|
||||||
|
zicross.overlays.zig
|
||||||
|
zicross.overlays.debian
|
||||||
|
zicross.overlays.windows
|
||||||
|
]
|
||||||
|
++ self.additional_overlays;
|
||||||
});
|
});
|
||||||
|
in {
|
||||||
in
|
additional_overlays = [
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
|
||||||
let
|
|
||||||
pkgs = import nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
|
|
||||||
overlays = [
|
|
||||||
#zicross.overlays.zig
|
|
||||||
#zicross.overlays.debian
|
|
||||||
#zicross.overlays.windows
|
|
||||||
|
|
||||||
(final: prev: {
|
(final: prev: {
|
||||||
#hello = with final; (if lib.strings.hasSuffix "windows" system then zigStdenv else stdenv).mkDerivation rec {
|
hello = with final;
|
||||||
hello = with final; stdenv.mkDerivation rec {
|
(
|
||||||
|
if lib.strings.hasSuffix "windows" system
|
||||||
|
then zigStdenv
|
||||||
|
else stdenv
|
||||||
|
)
|
||||||
|
.mkDerivation rec {
|
||||||
inherit version system;
|
inherit version system;
|
||||||
pname = "hello";
|
pname = "hello";
|
||||||
src = self;
|
src = self;
|
||||||
|
@ -70,42 +80,33 @@
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
packages = forAllSystems (system: let
|
||||||
|
pkgs = nixpkgsFor.${system};
|
||||||
|
in rec {
|
||||||
|
inherit (pkgs) hello;
|
||||||
|
default = hello;
|
||||||
|
lxc = pkgs.callPackage ./nix/lxc.nix {package = default;};
|
||||||
|
x86_64-windows = pkgs.callPackage ./nix/pkg-win64zip.nix {package = default;};
|
||||||
|
#x86_64-wix = pkgs.callPackage ./nix/pkg-win64-wix.nix { package = default; };
|
||||||
|
});
|
||||||
|
|
||||||
checks = {
|
checks = forAllSystems (system: {
|
||||||
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
||||||
src = ./.;
|
src = ./.;
|
||||||
hooks = {
|
hooks = {
|
||||||
nixpkgs-fmt.enable = true;
|
alejandra.enable = true;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
|
||||||
devShell = nixpkgs.legacyPackages.${system}.mkShell {
|
devShells.default = forAllSystems (system: import ./shell.nix {pkgs = nixpkgsFor.${system};});
|
||||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
in rec {
|
|
||||||
packages = {
|
|
||||||
inherit (pkgs) hello;
|
|
||||||
|
|
||||||
# This changes things in "packages" below of the form: "packages.x86_64-linux" into
|
# This changes things in "packages" below of the form: "packages.x86_64-linux" into
|
||||||
# "githubActions.targets.x86_64-linux.hello" so that the GHA matrix can iterate over them.
|
# "githubActions.targets.x86_64-linux.hello" so that the GHA matrix can iterate over them.
|
||||||
githubActions = nix-github-actions.lib.mkGithubMatrix {
|
githubActions = nix-github-actions.lib.mkGithubMatrix {
|
||||||
checks = nixpkgs.lib.getAttrs supportedSystems self.packages;
|
checks = nixpkgs.lib.getAttrs ["x86_64-linux" "x86_64-darwin"] self.packages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
formatter = forAllSystems (system: nixpkgsFor.${system}.alejandra);
|
||||||
};
|
};
|
||||||
packages.default = self.packages.${system}.hello;
|
|
||||||
|
|
||||||
#packages.lxc = pkgs.callPackage ./nix/lxc.nix { package = packages.default; };
|
|
||||||
#packages.x86_64-windows = pkgs.callPackage ./nix/pkg-win64zip.nix { package = packages.default; };
|
|
||||||
#packages.x86_64-wix = pkgs.callPackage ./nix/pkg-win64-wix.nix { inherit pkgs packages; };
|
|
||||||
|
|
||||||
#apps.hello = flake-utils.lib.mkApp { drv = packages.default; };
|
|
||||||
#apps.${system}.default = apps.hello;
|
|
||||||
|
|
||||||
#devShells.default = import ./shell.nix { inherit pkgs; };
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ pkgs, package }:
|
{
|
||||||
|
pkgs,
|
||||||
|
package,
|
||||||
|
}:
|
||||||
pkgs.dockerTools.buildImage {
|
pkgs.dockerTools.buildImage {
|
||||||
name = package.pname;
|
name = package.pname;
|
||||||
tag = ["latest" "0.1.0"]; #package.version
|
tag = ["latest" "0.1.0"]; #package.version
|
||||||
|
|
2
nix/overlays.nix
Normal file
2
nix/overlays.nix
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{pkgs}: {
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
{ pkgs, package }:
|
{
|
||||||
|
pkgs,
|
||||||
|
package,
|
||||||
|
}:
|
||||||
pkgs.packageForWindows package {
|
pkgs.packageForWindows package {
|
||||||
targetSystem = "x86_64-windows";
|
targetSystem = "x86_64-windows";
|
||||||
appendExe = ["hello"];
|
appendExe = ["hello"];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{pkgs ? import <nixpkgs> {}}:
|
{pkgs ? import <nixpkgs> {}}:
|
||||||
|
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
# nativeBuildInputs is usually what you want -- tools you need to run
|
#inherit (checks.${system}.pre-commit-check) shellHook;
|
||||||
nativeBuildInputs = with pkgs.buildPackages; [ ripgrep act ];
|
|
||||||
DOCKER_BUILDKIT = 1;
|
DOCKER_BUILDKIT = 1;
|
||||||
|
# nativeBuildInputs -- tools you need to run to facilitate the build
|
||||||
|
nativeBuildInputs = with pkgs.buildPackages; [ripgrep act];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue