packages: don't include self and inputs in perSystem

This commit is contained in:
Max Headroom 2023-01-08 19:07:20 +01:00
parent 43bc27c281
commit af019b1079
10 changed files with 291 additions and 279 deletions

View file

@ -1,17 +1,18 @@
{ pkgs, ... }:
{ {
imports = [ imports = [
./options.nix
./drv-parts ./drv-parts
]; ];
perSystem = { pkgs, ... }: {
imports = [
./options.nix
];
builders = rec { builders = rec {
fetchAsset = pkgs.callPackage ./fetch-asset { }; fetchAsset = pkgs.callPackage ./fetch-asset { };
hydrateAssetDirectory = pkgs.callPackage ./hydrate-asset-directory { hydrateAssetDirectory = pkgs.callPackage ./hydrate-asset-directory {
inherit fetchAsset; inherit fetchAsset;
};
}; };
}; };
} }

View file

@ -1,11 +1,12 @@
{ config, inputs, ... }: { inputs, ... }:
{ {
imports = [ perSystem = { config, ... }: {
./backends imports = [
./dependency-sets ./backends
]; ./dependency-sets
_module.args = { ];
drv-backends = inputs.drv-parts.drv-backends // config.drv-backends; _module.args = {
drv-backends = inputs.drv-parts.drv-backends // config.drv-backends;
};
}; };
} }

View file

@ -1,15 +1,18 @@
{ filters, pkgs, self, self', ... }: { self, ... }:
{
checks = filters.doFilter filters.checks {
keycloak = pkgs.callPackage ./keycloak-custom-jre.nix {
jre = self'.packages.jre17_standard;
};
patroni = pkgs.callPackage ./patroni.nix { {
patroniModule = self.nixosModules.patroni; perSystem = { filters, pkgs, self', ... }: {
}; checks = filters.doFilter filters.checks {
tempo = pkgs.callPackage ./tempo.nix { keycloak = pkgs.callPackage ./keycloak-custom-jre.nix {
inherit (self'.packages) tempo; jre = self'.packages.jre17_standard;
};
patroni = pkgs.callPackage ./patroni.nix {
patroniModule = self.nixosModules.patroni;
};
tempo = pkgs.callPackage ./tempo.nix {
inherit (self'.packages) tempo;
};
}; };
}; };
} }

View file

@ -1,67 +1,70 @@
{ lib, config, inputs', system, ... }: { lib, ... }:
with lib;
let
inherit (inputs'.devshell.legacyPackages) mkShell;
wrapInAttrs = value: if builtins.isAttrs value then value else { inherit value; }; {
perSystem = { config, inputs', system, ... }:
with lib;
let
inherit (inputs'.devshell.legacyPackages) mkShell;
wrapPackage = package: { inherit package; }; wrapInAttrs = value: if builtins.isAttrs value then value else { inherit value; };
injectAttrName = name: value: { inherit name; } // wrapInAttrs value; wrapPackage = package: { inherit package; };
mkNamedAttrs = builtins.mapAttrs injectAttrName; injectAttrName = name: value: { inherit name; } // wrapInAttrs value;
attrsToNamedList = attrs: builtins.attrValues (mkNamedAttrs attrs); mkNamedAttrs = builtins.mapAttrs injectAttrName;
mkProjectShell = attrsToNamedList = attrs: builtins.attrValues (mkNamedAttrs attrs);
{
packages ? [], mkProjectShell =
tools ? [], {
commands ? {}, packages ? [],
env ? {}, tools ? [],
config ? {} commands ? {},
}: env ? {},
mkShell { config ? {}
imports = [ }:
config mkShell {
{ imports = [
commands = map wrapPackage tools; config
} {
{ commands = map wrapPackage tools;
inherit packages; }
commands = attrsToNamedList commands; {
env = attrsToNamedList env; inherit packages;
} commands = attrsToNamedList commands;
]; env = attrsToNamedList env;
}
];
};
in {
options.projectShells = mkOption {
default = {};
type = types.attrsOf (types.submodule {
options = {
packages = mkOption {
default = [];
type = types.listOf types.package;
};
tools = mkOption {
default = [];
type = types.listOf types.package;
};
commands = mkOption {
default = {};
type = types.attrsOf types.attrs;
};
env = mkOption {
default = {};
type = with types; attrsOf (oneOf [ attrs str ] );
};
config = mkOption {
default = {};
type = types.anything;
};
};
});
};
config.devShells = lib.mkIf (system == "x86_64-linux") (mapAttrs (_: mkProjectShell) config.projectShells);
}; };
in {
options.projectShells = mkOption {
default = {};
type = types.attrsOf (types.submodule {
options = {
packages = mkOption {
default = [];
type = types.listOf types.package;
};
tools = mkOption {
default = [];
type = types.listOf types.package;
};
commands = mkOption {
default = {};
type = types.attrsOf types.attrs;
};
env = mkOption {
default = {};
type = with types; attrsOf (oneOf [ attrs str ] );
};
config = mkOption {
default = {};
type = types.anything;
};
};
});
};
config.devShells = lib.mkIf (system == "x86_64-linux") (mapAttrs (_: mkProjectShell) config.projectShells);
} }

View file

@ -1,40 +1,42 @@
{ inputs, lib, pkgs, ... }: { lib, inputs, ... }:
{ {
projectShells.hyprspace = { perSystem = { pkgs, ... }: {
tools = [ projectShells.hyprspace = {
pkgs.go_1_18 tools = [
]; pkgs.go_1_18
env.GOPATH.eval = "$REPO_DATA_DIR/go"; ];
}; env.GOPATH.eval = "$REPO_DATA_DIR/go";
packages.hyprspace = with pkgs; buildGo118Module {
pname = "hyprspace";
version = "0.3.2";
src = with inputs.nix-filter.lib; let
dirs = map inDirectory;
in filter {
root = ./.;
include = [
"go.mod"
"go.sum"
(matchExt "go")
] ++ (dirs [
"cli"
"config"
"p2p"
"tun"
]);
}; };
packages.hyprspace = with pkgs; buildGo118Module {
pname = "hyprspace";
version = "0.3.2";
vendorSha256 = "sha256-BiNWV/uNPnplwNfAvqf/Xc9ReFkLhHWVVeZrb/NI4bE="; src = with inputs.nix-filter.lib; let
dirs = map inDirectory;
in filter {
root = ./.;
include = [
"go.mod"
"go.sum"
(matchExt "go")
] ++ (dirs [
"cli"
"config"
"p2p"
"tun"
]);
};
meta = with lib; { vendorSha256 = "sha256-BiNWV/uNPnplwNfAvqf/Xc9ReFkLhHWVVeZrb/NI4bE=";
description = "A Lightweight VPN Built on top of Libp2p for Truly Distributed Networks.";
homepage = "https://github.com/hyprspace/hyprspace"; meta = with lib; {
license = licenses.asl20; description = "A Lightweight VPN Built on top of Libp2p for Truly Distributed Networks.";
maintainers = with maintainers; [ yusdacra ]; homepage = "https://github.com/hyprspace/hyprspace";
platforms = platforms.linux ++ platforms.darwin; license = licenses.asl20;
maintainers = with maintainers; [ yusdacra ];
platforms = platforms.linux ++ platforms.darwin;
};
}; };
}; };
} }

View file

@ -1,58 +1,59 @@
{ inputs, lib, pkgs, ... }: { inputs, ... }:
{ {
projectShells.ipfs-cluster = { perSystem = { lib, pkgs, ... }: {
tools = [ projectShells.ipfs-cluster = {
pkgs.go_1_19 tools = [
pkgs.gnumake pkgs.go_1_19
pkgs.gcc pkgs.gnumake
]; pkgs.gcc
env.GOPATH.eval = "$REPO_DATA_DIR/go"; ];
}; env.GOPATH.eval = "$REPO_DATA_DIR/go";
packages.ipfs-cluster = with pkgs; buildGo119Module {
pname = "ipfs-cluster";
version = "1.0.2";
src = with inputs.nix-filter.lib; filter {
root = ./.;
include = [
"go.mod"
"go.sum"
(matchExt "go")
] ++ (map inDirectory [
"adder"
"allocator"
"api"
"cmd"
"cmdutils"
"config"
"consensus"
"datastore"
"docker"
"informer"
"ipfsconn"
"monitor"
"observations"
"pintracker"
"pstoremgr"
"rpcutil"
"sharness"
"state"
"test"
"version"
]);
}; };
packages.ipfs-cluster = with pkgs; buildGo119Module {
pname = "ipfs-cluster";
version = "1.0.2";
vendorSha256 = "sha256-EpZQ7br+ChoAGIj0g6pdpWvFeOFOn2i+6YRBgtzoO+A="; src = with inputs.nix-filter.lib; filter {
root = ./.;
include = [
"go.mod"
"go.sum"
(matchExt "go")
] ++ (map inDirectory [
"adder"
"allocator"
"api"
"cmd"
"cmdutils"
"config"
"consensus"
"datastore"
"docker"
"informer"
"ipfsconn"
"monitor"
"observations"
"pintracker"
"pstoremgr"
"rpcutil"
"sharness"
"state"
"test"
"version"
]);
};
doCheck = false; vendorSha256 = "sha256-EpZQ7br+ChoAGIj0g6pdpWvFeOFOn2i+6YRBgtzoO+A=";
meta = with lib; { doCheck = false;
description = "Allocate, replicate, and track Pins across a cluster of IPFS daemons";
homepage = "https://ipfscluster.io"; meta = with lib; {
license = licenses.mit; description = "Allocate, replicate, and track Pins across a cluster of IPFS daemons";
platforms = platforms.unix; homepage = "https://ipfscluster.io";
maintainers = with maintainers; [ Luflosi jglukasik ]; license = licenses.mit;
}; platforms = platforms.unix;
maintainers = with maintainers; [ Luflosi jglukasik ];
};
};
}; };
} }

View file

@ -1,6 +1,17 @@
{ inputs, self, ... }: { inputs, self, ... }:
{ {
imports = [
./checks
./modules/devshell.nix
./build-support
./networking/hyprspace/project.nix
./networking/ipfs-cluster/project.nix
./servers/reflex-cache/project.nix
./websites/landing/project.nix
./websites/stop-using-nix-env/project.nix
];
perSystem = { filters, pkgs, self', ... }: perSystem = { filters, pkgs, self', ... }:
let let
inherit (self'.packages) nix-super; inherit (self'.packages) nix-super;
@ -16,19 +27,6 @@
}; };
in in
{ {
_module.args = { inherit inputs self; };
imports = [
./checks
./modules/devshell.nix
./build-support
./networking/hyprspace/project.nix
./networking/ipfs-cluster/project.nix
./servers/reflex-cache/project.nix
./websites/landing/project.nix
./websites/stop-using-nix-env/project.nix
];
packages = filters.doFilter filters.packages rec { packages = filters.doFilter filters.packages rec {
cinny = pkgs.callPackage ./web-apps/cinny { inherit pins; }; cinny = pkgs.callPackage ./web-apps/cinny { inherit pins; };

View file

@ -1,38 +1,40 @@
{ config, drv-backends, inputs, lib, pkgs, ... }: { inputs, ... }:
let
deps = with config.dependencySets.python3Packages; [
poetry-core
requests-unixsocket
py-multibase
py-multiaddr
];
pythonForDev = pkgs.python3.withPackages (lib.const deps);
in
{ {
projectShells.reflex-cache = { perSystem = { config, drv-backends, lib, pkgs, ... }: let
tools = [ deps = with config.dependencySets.python3Packages; [
pythonForDev poetry-core
requests-unixsocket
py-multibase
py-multiaddr
]; ];
env.PYTHON = pythonForDev.interpreter;
commands.reflex.command = "${pythonForDev.interpreter} -m reflex_cache.main";
};
drvs.reflex-cache = { dependencySets, ... }: {
imports = [
drv-backends.buildPythonPackage
];
pyprojectToml = ./pyproject.toml;
inherit (pkgs) stdenv;
propagatedBuildInputs = deps; pythonForDev = pkgs.python3.withPackages (lib.const deps);
in
src = with inputs.nix-filter.lib; filter { {
root = ./.; projectShells.reflex-cache = {
include = [ tools = [
"pyproject.toml" pythonForDev
(inDirectory "reflex_cache")
]; ];
env.PYTHON = pythonForDev.interpreter;
commands.reflex.command = "${pythonForDev.interpreter} -m reflex_cache.main";
};
drvs.reflex-cache = { dependencySets, ... }: {
imports = [
drv-backends.buildPythonPackage
];
pyprojectToml = ./pyproject.toml;
inherit (pkgs) stdenv;
propagatedBuildInputs = deps;
src = with inputs.nix-filter.lib; filter {
root = ./.;
include = [
"pyproject.toml"
(inDirectory "reflex_cache")
];
};
}; };
}; };
} }

View file

@ -1,54 +1,55 @@
{ builders, lib, pkgs, self', ... }:
let
configFile = pkgs.writeText "hugo-config.json" (builtins.toJSON {
title = "Private Void | Zero-maintenance perfection";
baseURL = "https://www.privatevoid.net/";
languageCode = "en-us";
disableKinds = [
"page"
"RSS"
"section"
"sitemap"
"taxonomy"
"taxonomyTerm"
];
});
hugoArgs = [
"--config" configFile
];
hugoArgsStr = lib.concatStringsSep " " hugoArgs;
in
{ {
projectShells.landing = { perSystem = { builders, lib, pkgs, self', ... }: let
commands.hugo = { configFile = pkgs.writeText "hugo-config.json" (builtins.toJSON {
help = pkgs.hugo.meta.description; title = "Private Void | Zero-maintenance perfection";
command = "exec ${pkgs.hugo}/bin/hugo ${hugoArgsStr} \"$@\""; baseURL = "https://www.privatevoid.net/";
}; languageCode = "en-us";
tools = with self'.packages; [ disableKinds = [
dvc "page"
]; "RSS"
}; "section"
"sitemap"
packages.landing = with pkgs; let "taxonomy"
site = stdenvNoCC.mkDerivation rec { "taxonomyTerm"
pname = "private-void-landing-page";
version = "0.0.0";
src = builders.hydrateAssetDirectory ./.;
nativeBuildInputs = [
hugo
]; ];
buildCommand = '' });
unpackPhase hugoArgs = [
mkdir -p $out/share/www "--config" configFile
hugo ${hugoArgsStr} -s $sourceRoot -d $out/share/www/${pname} ];
''; hugoArgsStr = lib.concatStringsSep " " hugoArgs;
passthru = { in
webroot = "${site}/share/www/${site.pname}"; {
serve = writeShellScriptBin "serve-site" '' projectShells.landing = {
command -v xdg-open >/dev/null && xdg-open http://127.0.0.1:1314 || true commands.hugo = {
${darkhttpd}/bin/darkhttpd ${site.webroot} --addr 127.0.0.1 --port 1314 help = pkgs.hugo.meta.description;
''; command = "exec ${pkgs.hugo}/bin/hugo ${hugoArgsStr} \"$@\"";
}; };
tools = with self'.packages; [
dvc
];
}; };
in site;
packages.landing = with pkgs; let
site = stdenvNoCC.mkDerivation rec {
pname = "private-void-landing-page";
version = "0.0.0";
src = builders.hydrateAssetDirectory ./.;
nativeBuildInputs = [
hugo
];
buildCommand = ''
unpackPhase
mkdir -p $out/share/www
hugo ${hugoArgsStr} -s $sourceRoot -d $out/share/www/${pname}
'';
passthru = {
webroot = "${site}/share/www/${site.pname}";
serve = writeShellScriptBin "serve-site" ''
command -v xdg-open >/dev/null && xdg-open http://127.0.0.1:1314 || true
${darkhttpd}/bin/darkhttpd ${site.webroot} --addr 127.0.0.1 --port 1314
'';
};
};
in site;
};
} }

View file

@ -1,19 +1,19 @@
{ pkgs, ... }:
{ {
packages.stop-using-nix-env = let perSystem = { pkgs, ... }: {
site = with pkgs; stdenvNoCC.mkDerivation rec { packages.stop-using-nix-env = let
pname = "stop-using-nix-env"; site = with pkgs; stdenvNoCC.mkDerivation rec {
version = "1.2.0"; pname = "stop-using-nix-env";
src = ./src; version = "1.2.0";
buildCommand = '' src = ./src;
install -Dm644 $src/* -t $out/share/www/${pname} buildCommand = ''
substituteInPlace $out/share/www/${pname}/index.html \ install -Dm644 $src/* -t $out/share/www/${pname}
--replace '<!-- VERSION -->' 'Version ${version} |' substituteInPlace $out/share/www/${pname}/index.html \
''; --replace '<!-- VERSION -->' 'Version ${version} |'
passthru = { '';
webroot = "${site}/share/www/${pname}"; passthru = {
webroot = "${site}/share/www/${pname}";
};
}; };
}; in site;
in site; };
} }