meta: convert /packages to Flake Parts

This commit is contained in:
Max Headroom 2022-07-31 15:09:40 +02:00
parent a11b4b346d
commit 1b40e420a3
7 changed files with 166 additions and 163 deletions

View file

@ -105,28 +105,20 @@
mkDeployments = hosts: overrides: lib.genAttrs hosts
(host: mkDeploy host // (overrides.${host} or {}) );
depot = forSystems (system: import ./packages {
inherit inputs system;
pkgs = nixpkgsFor system;
});
effects = inputs.hercules-ci-effects.lib.withPkgs (nixpkgsFor "x86_64-linux");
in {
in flake-parts.lib.mkFlake { inherit self; } {
inherit systems;
flake = {
nixosModules = aspect.modules;
nixosConfigurations = lib.genAttrs nixosHosts mkNixOS;
deploy.nodes = mkDeployments deployableNixosHosts {};
apps = forSystems (system: {
});
packages = forSystems (system: depot.${system}.packages);
checks = forSystems (system: depot.${system}.checks);
devShells = forSystems (system: depot.${system}.devShells);
effects = { branch, ... }: mkDeployEffects branch deployableNixosHosts;
};
imports = [
./packages/part.nix
];
};
}

View file

@ -1,19 +0,0 @@
{ pkgs, inputs, system }@args:
let
patched-derivations = import ./patched-derivations.nix (pkgs // { flakePackages = all; });
patched-inputs = import ./patched-inputs.nix args;
projects = import ./projects.nix args;
all = patched-derivations
// patched-inputs
// projects.packages;
filters = import ./system-filter.nix;
doFilter = filterSet: pkgSet: pkgs.lib.filterAttrs (name: _:
filterSet ? "${name}" -> builtins.elem system filterSet."${name}"
) pkgSet;
in {
packages = doFilter filters.packages all;
checks = doFilter filters.checks projects.checks;
inherit (projects) devShells;
}

View file

@ -1,8 +1,6 @@
{ inputs, pkgs, ... }:
{ inputs', pkgs, ... }:
let
inherit (pkgs) system;
inherit (inputs.devshell.legacyPackages.${system}) mkShell;
inherit (inputs'.devshell.legacyPackages) mkShell;
wrapInAttrs = value: if builtins.isAttrs value then value else { inherit value; };

18
packages/part.nix Normal file
View file

@ -0,0 +1,18 @@
{ inputs, lib, ... }:
let
filters = import ./system-filter.nix;
doFilter' = system: filterSet: pkgSet: lib.filterAttrs (name: _:
filterSet ? "${name}" -> builtins.elem system filterSet."${name}"
) pkgSet;
in {
imports = [
./projects.nix
./patched-inputs.nix
];
perSystem = { pkgs, self', system, ... }: let
patched-derivations = import ./patched-derivations.nix (pkgs // { flakePackages = self'.packages; });
in {
_module.args.filters = filters // { doFilter = doFilter' system; };
packages = doFilter' system filters.packages patched-derivations;
};
}

View file

@ -1,9 +1,13 @@
{ inputs, pkgs, system, ... }:
let
{
perSystem = { filters, inputs', ... }:
let
tools = import ./lib/tools.nix;
packages = builtins.mapAttrs (_: v: v.packages.${system}) inputs;
in with tools;
rec {
packages = builtins.mapAttrs (_: v: v.packages) inputs';
in with tools;
{
packages = filters.doFilter filters.packages rec {
inherit (packages.deploy-rs) deploy-rs;
nix-super = packages.nix-super.nix;
@ -13,4 +17,6 @@ rec {
hercules-ci-agent = packages.hercules-ci-agent.hercules-ci-agent;
hci = packages.hercules-ci-agent.hercules-ci-cli;
};
};
}

View file

@ -1,8 +1,10 @@
{ pkgs, inputs, system, ... }@args:
let
{ inputs, self, ... }:
{
perSystem = { filters, inputs', pkgs, self', system, ... }:
let
inherit (pkgs) lib;
inherit (inputs) unstable;
inherit (inputs.self.packages.${system}) nix-super;
inherit (self'.packages) nix-super;
pins = import ./sources;
@ -17,11 +19,16 @@ let
defaultPoetryOverrides = prev.defaultPoetryOverrides.extend (import ./poetry2nix-overrides);
});
mkShell = import lib/devshell.nix args;
mkShell = import lib/devshell.nix {
inherit inputs' pkgs;
};
in
{
packages = rec {
in
{
imports = [
./tests
];
packages = filters.doFilter filters.packages rec {
ghost = let
version = "4.41.3";
dream = dream2nix.makeOutputs {
@ -77,11 +84,9 @@ in
stevenblack-hosts = pkgs.callPackage ./data/stevenblack { inherit pins; };
};
checks = import ./tests { inherit inputs pkgs system; };
devShells = {
default = let
flakePkgs = inputs.self.packages.${system};
flakePkgs = self'.packages;
in mkShell {
tools = with flakePkgs; [
agenix
@ -93,7 +98,7 @@ in
env.NPINS_DIRECTORY.eval = "$REPO_ROOT/packages/sources";
};
reflex-cache = let
inherit (inputs.self.packages.${system}) reflex-cache;
inherit (self'.packages) reflex-cache;
in mkShell {
packages = [
reflex-cache.dependencyEnv
@ -106,4 +111,5 @@ in
env.PYTHON = reflex-cache.dependencyEnv.interpreter;
};
};
};
}

View file

@ -1,13 +1,14 @@
{ inputs, pkgs, system }:
{ filters, inputs', pkgs, self', ... }:
let
inherit (pkgs) nixosTest;
in
{
checks = filters.doFilter filters.checks {
keycloak = nixosTest {
name = "keycloak";
nodes.machine.services.keycloak = {
enable = true;
package = pkgs.keycloak.override { jre = inputs.self.packages.${system}.jre17_standard; };
package = pkgs.keycloak.override { jre = self'.packages.jre17_standard; };
database.passwordFile = builtins.toFile "keycloak-test-password" "kcnixostest1234";
settings = {
proxy = "edge";
@ -20,4 +21,5 @@ in
machine.succeed("curl --fail http://127.0.0.1:80")
'';
};
};
}