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

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 let
inherit (pkgs) system; inherit (inputs'.devshell.legacyPackages) mkShell;
inherit (inputs.devshell.legacyPackages.${system}) mkShell;
wrapInAttrs = value: if builtins.isAttrs value then value else { inherit value; }; 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,16 +1,22 @@
{ inputs, pkgs, system, ... }: {
let perSystem = { filters, inputs', ... }:
tools = import ./lib/tools.nix;
packages = builtins.mapAttrs (_: v: v.packages.${system}) inputs;
in with tools;
rec {
inherit (packages.deploy-rs) deploy-rs;
nix-super = packages.nix-super.nix; let
tools = import ./lib/tools.nix;
packages = builtins.mapAttrs (_: v: v.packages) inputs';
in with tools;
agenix = packages.agenix.agenix.override { nix = nix-super; }; {
packages = filters.doFilter filters.packages rec {
inherit (packages.deploy-rs) deploy-rs;
hercules-ci-agent = packages.hercules-ci-agent.hercules-ci-agent; nix-super = packages.nix-super.nix;
hci = packages.hercules-ci-agent.hercules-ci-cli; agenix = packages.agenix.agenix.override { nix = nix-super; };
}
hercules-ci-agent = packages.hercules-ci-agent.hercules-ci-agent;
hci = packages.hercules-ci-agent.hercules-ci-cli;
};
};
}

View file

@ -1,109 +1,115 @@
{ pkgs, inputs, system, ... }@args: { inputs, self, ... }:
let
inherit (pkgs) lib;
inherit (inputs) unstable;
inherit (inputs.self.packages.${system}) nix-super;
pins = import ./sources;
dream2nix = inputs.dream2nix.lib2.init {
inherit pkgs;
config = {
projectRoot = ./.;
overridesDirs = [ ./dream2nix-overrides ];
};
};
poetry2nix = pkgs.poetry2nix.overrideScope' (final: prev: {
defaultPoetryOverrides = prev.defaultPoetryOverrides.extend (import ./poetry2nix-overrides);
});
mkShell = import lib/devshell.nix args;
in
{ {
packages = rec { perSystem = { filters, inputs', pkgs, self', system, ... }:
ghost = let let
version = "4.41.3"; inherit (pkgs) lib;
dream = dream2nix.makeOutputs { inherit (self'.packages) nix-super;
source = pkgs.fetchzip {
url = "https://github.com/TryGhost/Ghost/releases/download/v${version}/Ghost-${version}.zip"; pins = import ./sources;
sha256 = "sha256-mqN43LSkd9MHoIHyGS1VsPvpqWqX4Bx5KHcp3KOHw5A=";
stripRoot = false; dream2nix = inputs.dream2nix.lib2.init {
inherit pkgs;
config = {
projectRoot = ./.;
overridesDirs = [ ./dream2nix-overrides ];
};
};
poetry2nix = pkgs.poetry2nix.overrideScope' (final: prev: {
defaultPoetryOverrides = prev.defaultPoetryOverrides.extend (import ./poetry2nix-overrides);
});
mkShell = import lib/devshell.nix {
inherit inputs' pkgs;
};
in
{
imports = [
./tests
];
packages = filters.doFilter filters.packages rec {
ghost = let
version = "4.41.3";
dream = dream2nix.makeOutputs {
source = pkgs.fetchzip {
url = "https://github.com/TryGhost/Ghost/releases/download/v${version}/Ghost-${version}.zip";
sha256 = "sha256-mqN43LSkd9MHoIHyGS1VsPvpqWqX4Bx5KHcp3KOHw5A=";
stripRoot = false;
};
};
inherit (dream.packages) ghost;
in
ghost;
uptime-kuma = let
dream = dream2nix.makeOutputs {
source = pins.uptime-kuma;
};
inherit (dream.packages) uptime-kuma;
in
uptime-kuma;
grafana = pkgs.callPackage ./monitoring/grafana { };
hyprspace = pkgs.callPackage ./networking/hyprspace { iproute2mac = null; };
ipfs = pkgs.callPackage ./networking/ipfs { };
npins = pkgs.callPackage ./tools/npins {
nix = nix-super;
nix-prefetch-git = pkgs.nix-prefetch-git.override {
nix = nix-super;
}; };
}; };
inherit (dream.packages) ghost;
in
ghost;
uptime-kuma = let opentelemetry-java-agent-bin = pkgs.callPackage ./monitoring/opentelemetry-java-agent-bin { };
dream = dream2nix.makeOutputs {
source = pins.uptime-kuma;
};
inherit (dream.packages) uptime-kuma;
in
uptime-kuma;
grafana = pkgs.callPackage ./monitoring/grafana { }; pin = pkgs.callPackage ./tools/pin {
inherit npins;
hyprspace = pkgs.callPackage ./networking/hyprspace { iproute2mac = null; };
ipfs = pkgs.callPackage ./networking/ipfs { };
npins = pkgs.callPackage ./tools/npins {
nix = nix-super;
nix-prefetch-git = pkgs.nix-prefetch-git.override {
nix = nix-super; nix = nix-super;
}; };
privatevoid-smart-card-ca-bundle = pkgs.callPackage ./data/privatevoid-smart-card-certificate-authority-bundle.nix { };
reflex-cache = poetry2nix.mkPoetryApplication {
projectDir = ./servers/reflex-cache;
meta.mainProgram = "reflex";
};
searxng = pkgs.callPackage ./web-apps/searxng { inherit pins; };
sips = pkgs.callPackage ./servers/sips { };
stevenblack-hosts = pkgs.callPackage ./data/stevenblack { inherit pins; };
}; };
opentelemetry-java-agent-bin = pkgs.callPackage ./monitoring/opentelemetry-java-agent-bin { }; devShells = {
default = let
flakePkgs = self'.packages;
in mkShell {
tools = with flakePkgs; [
agenix
deploy-rs
npins
pin
];
pin = pkgs.callPackage ./tools/pin { env.NPINS_DIRECTORY.eval = "$REPO_ROOT/packages/sources";
inherit npins; };
nix = nix-super; reflex-cache = let
}; inherit (self'.packages) reflex-cache;
in mkShell {
privatevoid-smart-card-ca-bundle = pkgs.callPackage ./data/privatevoid-smart-card-certificate-authority-bundle.nix { }; packages = [
reflex-cache.dependencyEnv
reflex-cache = poetry2nix.mkPoetryApplication { ];
projectDir = ./servers/reflex-cache;
meta.mainProgram = "reflex";
};
searxng = pkgs.callPackage ./web-apps/searxng { inherit pins; };
sips = pkgs.callPackage ./servers/sips { };
stevenblack-hosts = pkgs.callPackage ./data/stevenblack { inherit pins; };
};
checks = import ./tests { inherit inputs pkgs system; };
devShells = {
default = let
flakePkgs = inputs.self.packages.${system};
in mkShell {
tools = with flakePkgs; [
agenix
deploy-rs
npins
pin
];
env.NPINS_DIRECTORY.eval = "$REPO_ROOT/packages/sources";
};
reflex-cache = let
inherit (inputs.self.packages.${system}) reflex-cache;
in mkShell {
packages = [
reflex-cache.dependencyEnv
];
tools = [ tools = [
pkgs.poetry pkgs.poetry
]; ];
env.PYTHON = reflex-cache.dependencyEnv.interpreter; env.PYTHON = reflex-cache.dependencyEnv.interpreter;
};
}; };
}; };
} }

View file

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