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 {
nixosModules = aspect.modules;
in flake-parts.lib.mkFlake { inherit self; } {
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: {
});
packages = forSystems (system: depot.${system}.packages);
checks = forSystems (system: depot.${system}.checks);
devShells = forSystems (system: depot.${system}.devShells);
effects = { branch, ... }: mkDeployEffects branch deployableNixosHosts;
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,16 +1,22 @@
{ inputs, pkgs, system, ... }:
let
tools = import ./lib/tools.nix;
packages = builtins.mapAttrs (_: v: v.packages.${system}) inputs;
in with tools;
rec {
inherit (packages.deploy-rs) deploy-rs;
{
perSystem = { filters, inputs', ... }:
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:
let
inherit (pkgs) lib;
inherit (inputs) unstable;
inherit (inputs.self.packages.${system}) nix-super;
{ inputs, self, ... }:
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 {
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;
perSystem = { filters, inputs', pkgs, self', system, ... }:
let
inherit (pkgs) lib;
inherit (self'.packages) 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 {
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
dream = dream2nix.makeOutputs {
source = pins.uptime-kuma;
};
inherit (dream.packages) uptime-kuma;
in
uptime-kuma;
opentelemetry-java-agent-bin = pkgs.callPackage ./monitoring/opentelemetry-java-agent-bin { };
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 {
pin = pkgs.callPackage ./tools/pin {
inherit npins;
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 {
inherit npins;
nix = nix-super;
};
env.NPINS_DIRECTORY.eval = "$REPO_ROOT/packages/sources";
};
reflex-cache = let
inherit (self'.packages) reflex-cache;
in mkShell {
packages = [
reflex-cache.dependencyEnv
];
privatevoid-smart-card-ca-bundle = pkgs.callPackage ./data/privatevoid-smart-card-certificate-authority-bundle.nix { };
tools = [
pkgs.poetry
];
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 = [
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
inherit (pkgs) nixosTest;
in
{
keycloak = nixosTest {
name = "keycloak";
nodes.machine.services.keycloak = {
enable = true;
package = pkgs.keycloak.override { jre = inputs.self.packages.${system}.jre17_standard; };
database.passwordFile = builtins.toFile "keycloak-test-password" "kcnixostest1234";
settings = {
proxy = "edge";
hostname = "keycloak.local";
checks = filters.doFilter filters.checks {
keycloak = nixosTest {
name = "keycloak";
nodes.machine.services.keycloak = {
enable = true;
package = pkgs.keycloak.override { jre = self'.packages.jre17_standard; };
database.passwordFile = builtins.toFile "keycloak-test-password" "kcnixostest1234";
settings = {
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")
'';
};
}