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 = [
./options.nix
./drv-parts
];
perSystem = { pkgs, ... }: {
imports = [
./options.nix
];
builders = rec {
fetchAsset = pkgs.callPackage ./fetch-asset { };
builders = rec {
fetchAsset = pkgs.callPackage ./fetch-asset { };
hydrateAssetDirectory = pkgs.callPackage ./hydrate-asset-directory {
inherit fetchAsset;
hydrateAssetDirectory = pkgs.callPackage ./hydrate-asset-directory {
inherit fetchAsset;
};
};
};
}

View file

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

View file

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

View file

@ -1,67 +1,70 @@
{ lib, config, inputs', system, ... }:
with lib;
let
inherit (inputs'.devshell.legacyPackages) mkShell;
{ lib, ... }:
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 =
{
packages ? [],
tools ? [],
commands ? {},
env ? {},
config ? {}
}:
mkShell {
imports = [
config
{
commands = map wrapPackage tools;
}
{
inherit packages;
commands = attrsToNamedList commands;
env = attrsToNamedList env;
}
];
attrsToNamedList = attrs: builtins.attrValues (mkNamedAttrs attrs);
mkProjectShell =
{
packages ? [],
tools ? [],
commands ? {},
env ? {},
config ? {}
}:
mkShell {
imports = [
config
{
commands = map wrapPackage tools;
}
{
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 = {
tools = [
pkgs.go_1_18
];
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"
]);
perSystem = { pkgs, ... }: {
projectShells.hyprspace = {
tools = [
pkgs.go_1_18
];
env.GOPATH.eval = "$REPO_DATA_DIR/go";
};
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; {
description = "A Lightweight VPN Built on top of Libp2p for Truly Distributed Networks.";
homepage = "https://github.com/hyprspace/hyprspace";
license = licenses.asl20;
maintainers = with maintainers; [ yusdacra ];
platforms = platforms.linux ++ platforms.darwin;
vendorSha256 = "sha256-BiNWV/uNPnplwNfAvqf/Xc9ReFkLhHWVVeZrb/NI4bE=";
meta = with lib; {
description = "A Lightweight VPN Built on top of Libp2p for Truly Distributed Networks.";
homepage = "https://github.com/hyprspace/hyprspace";
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 = {
tools = [
pkgs.go_1_19
pkgs.gnumake
pkgs.gcc
];
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"
]);
perSystem = { lib, pkgs, ... }: {
projectShells.ipfs-cluster = {
tools = [
pkgs.go_1_19
pkgs.gnumake
pkgs.gcc
];
env.GOPATH.eval = "$REPO_DATA_DIR/go";
};
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; {
description = "Allocate, replicate, and track Pins across a cluster of IPFS daemons";
homepage = "https://ipfscluster.io";
license = licenses.mit;
platforms = platforms.unix;
maintainers = with maintainers; [ Luflosi jglukasik ];
};
doCheck = false;
meta = with lib; {
description = "Allocate, replicate, and track Pins across a cluster of IPFS daemons";
homepage = "https://ipfscluster.io";
license = licenses.mit;
platforms = platforms.unix;
maintainers = with maintainers; [ Luflosi jglukasik ];
};
};
};
}

View file

@ -1,6 +1,17 @@
{ 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', ... }:
let
inherit (self'.packages) nix-super;
@ -16,19 +27,6 @@
};
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 {
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 = {
tools = [
pythonForDev
perSystem = { config, drv-backends, lib, pkgs, ... }: let
deps = with config.dependencySets.python3Packages; [
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;
src = with inputs.nix-filter.lib; filter {
root = ./.;
include = [
"pyproject.toml"
(inDirectory "reflex_cache")
pythonForDev = pkgs.python3.withPackages (lib.const deps);
in
{
projectShells.reflex-cache = {
tools = [
pythonForDev
];
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 = {
commands.hugo = {
help = pkgs.hugo.meta.description;
command = "exec ${pkgs.hugo}/bin/hugo ${hugoArgsStr} \"$@\"";
};
tools = with self'.packages; [
dvc
];
};
packages.landing = with pkgs; let
site = stdenvNoCC.mkDerivation rec {
pname = "private-void-landing-page";
version = "0.0.0";
src = builders.hydrateAssetDirectory ./.;
nativeBuildInputs = [
hugo
perSystem = { 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"
];
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
'';
});
hugoArgs = [
"--config" configFile
];
hugoArgsStr = lib.concatStringsSep " " hugoArgs;
in
{
projectShells.landing = {
commands.hugo = {
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
site = with pkgs; stdenvNoCC.mkDerivation rec {
pname = "stop-using-nix-env";
version = "1.2.0";
src = ./src;
buildCommand = ''
install -Dm644 $src/* -t $out/share/www/${pname}
substituteInPlace $out/share/www/${pname}/index.html \
--replace '<!-- VERSION -->' 'Version ${version} |'
'';
passthru = {
webroot = "${site}/share/www/${pname}";
perSystem = { pkgs, ... }: {
packages.stop-using-nix-env = let
site = with pkgs; stdenvNoCC.mkDerivation rec {
pname = "stop-using-nix-env";
version = "1.2.0";
src = ./src;
buildCommand = ''
install -Dm644 $src/* -t $out/share/www/${pname}
substituteInPlace $out/share/www/${pname}/index.html \
--replace '<!-- VERSION -->' 'Version ${version} |'
'';
passthru = {
webroot = "${site}/share/www/${pname}";
};
};
};
in site;
in site;
};
}