refactor(flake)!: export packages using a flake module
Also stop passing `outputs` around, prefer `inputs.self` Also put all `auto_` in `readOnly` `internal` options - `autoModules`, `autoConfigurations` and `autoPackages` Do not export packages as overlay (causes an infinite recursion) - this is documented on the two places it has effect on -- in `./overlays/default.nix` and `./modules/flake/configurations.nix` -- in `autoConfigurations` we manually extend `pkgs` with the flake packages Allow packages to say what `systems` they are compatible with - See `./pkgs/swww/systems.nix` - disabled for all systems - See `./pkgs/pngpaste/systems.nix` - enabled only for `darwin` targets
This commit is contained in:
parent
e45db02cd5
commit
2941536b80
36 changed files with 241 additions and 118 deletions
14
flake.nix
14
flake.nix
|
@ -150,17 +150,20 @@
|
||||||
./modules/flake/agenix.nix
|
./modules/flake/agenix.nix
|
||||||
./modules/flake/deploy.nix
|
./modules/flake/deploy.nix
|
||||||
./modules/flake/topology
|
./modules/flake/topology
|
||||||
|
./modules/flake/packages
|
||||||
];
|
];
|
||||||
|
|
||||||
perSystem = { lib, pkgs, system, ... }: {
|
|
||||||
# Packages (`nix build`)
|
|
||||||
packages = import ./pkgs { inherit pkgs; };
|
|
||||||
|
|
||||||
|
perSystem = { lib, pkgs, system, ... }: {
|
||||||
# Apps (`nix run`)
|
# Apps (`nix run`)
|
||||||
apps = import ./apps { inherit pkgs; };
|
apps = import ./apps { inherit pkgs; };
|
||||||
|
|
||||||
# Dev Shells (`nix develop`)
|
# Dev Shells (`nix develop`)
|
||||||
devShells = import ./shells { inherit pkgs inputs; };
|
devShells = import ./shells {
|
||||||
|
inherit inputs;
|
||||||
|
# NOTE: for `nixVersions.monitored`
|
||||||
|
pkgs = pkgs.extend inputs.self.overlays.modifications;
|
||||||
|
};
|
||||||
|
|
||||||
# Formatter (`nix fmt`)
|
# Formatter (`nix fmt`)
|
||||||
formatter = pkgs.nixpkgs-fmt;
|
formatter = pkgs.nixpkgs-fmt;
|
||||||
|
@ -175,6 +178,9 @@
|
||||||
# Automatic configurations, see `./modules/flake/configurations.nix`
|
# Automatic configurations, see `./modules/flake/configurations.nix`
|
||||||
autoConfigurations.enableAll = true;
|
autoConfigurations.enableAll = true;
|
||||||
|
|
||||||
|
# Automatic packages, see `./modules/flake/packages/default.nix`
|
||||||
|
autoPackages.enable = true;
|
||||||
|
|
||||||
# Templates
|
# Templates
|
||||||
templates = import ./templates {
|
templates = import ./templates {
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# This is your home-manager configuration file
|
# This is your home-manager configuration file
|
||||||
# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix)
|
# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix)
|
||||||
|
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }: {
|
{ inputs, lib, pkgs, config, ... }: {
|
||||||
# You can import other home-manager modules here
|
# You can import other home-manager modules here
|
||||||
imports = [
|
imports = [
|
||||||
# If you want to use modules your own flake exports (from modules/home-manager):
|
# If you want to use modules your own flake exports (from modules/home-manager):
|
||||||
# outputs.homeManagerModules.example
|
# inputs.self.homeManagerModules.example
|
||||||
|
|
||||||
# Or modules exported from other flakes (such as nix-colors):
|
# Or modules exported from other flakes (such as nix-colors):
|
||||||
# inputs.nix-colors.homeManagerModules.default
|
# inputs.nix-colors.homeManagerModules.default
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [ ];
|
environment.systemPackages = with pkgs; [ ];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
home = {
|
home = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [ ];
|
environment.systemPackages = with pkgs; [ ];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
home = {
|
home = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [ ];
|
environment.systemPackages = with pkgs; [ ];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
home = {
|
home = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
environment.packages = with pkgs; [ ];
|
environment.packages = with pkgs; [ ];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
# Home Manager needs a bit of information about you and the
|
# Home Manager needs a bit of information about you and the
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# This is your system's configuration file.
|
# This is your system's configuration file.
|
||||||
# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix)
|
# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix)
|
||||||
|
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }: {
|
{ inputs, lib, pkgs, config, ... }: {
|
||||||
# You can import other NixOS modules here
|
# You can import other NixOS modules here
|
||||||
imports = [
|
imports = [
|
||||||
# If you want to use modules your own flake exports (from modules/nixos):
|
# If you want to use modules your own flake exports (from modules/nixos):
|
||||||
# outputs.nixosModules.example
|
# inputs.self.nixosModules.example
|
||||||
|
|
||||||
# Or modules from other flakes (such as nixos-hardware):
|
# Or modules from other flakes (such as nixos-hardware):
|
||||||
# inputs.hardware.nixosModules.common-cpu-amd
|
# inputs.hardware.nixosModules.common-cpu-amd
|
||||||
|
@ -22,8 +22,8 @@
|
||||||
# You can add overlays here
|
# You can add overlays here
|
||||||
overlays = [
|
overlays = [
|
||||||
# If you want to use overlays your own flake exports (from overlays dir):
|
# If you want to use overlays your own flake exports (from overlays dir):
|
||||||
# outputs.overlays.modifications
|
# inputs.self.overlays.modifications
|
||||||
# outputs.overlays.additions
|
# inputs.self.overlays.additions
|
||||||
|
|
||||||
# Or overlays exported from other flakes:
|
# Or overlays exported from other flakes:
|
||||||
# neovim-nightly-overlay.overlays.default
|
# neovim-nightly-overlay.overlays.default
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# your system. Help is available in the configuration.nix(5) man page
|
# your system. Help is available in the configuration.nix(5) man page
|
||||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||||
|
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.hardware.nixosModules.common-cpu-amd
|
inputs.hardware.nixosModules.common-cpu-amd
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
# age.secrets."nextcloud.adminpass" = {
|
# age.secrets."nextcloud.adminpass" = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
{
|
{
|
||||||
networking.firewall.allowedTCPPorts = [11434];
|
networking.firewall.allowedTCPPorts = [11434];
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, ... }:
|
{ inputs, lib, pkgs, config, ... }:
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
wireguard-tools
|
wireguard-tools
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
{ lib, config, self, inputs, withSystem, ... }:
|
{ lib, config, self, inputs, withSystem, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
outputs = self;
|
inherit (import ../../nix/utils.nix { inherit lib config self; })
|
||||||
inherit (import ../../nix/utils.nix { inherit lib self; })
|
|
||||||
and
|
and
|
||||||
hasFiles
|
hasFiles
|
||||||
hasDirectories
|
hasDirectories
|
||||||
recurseDir
|
recurseDir
|
||||||
configuration-type-to-outputs-modules
|
configuration-type-to-outputs-modules;
|
||||||
configuration-type-to-outputs-hosts;
|
|
||||||
in
|
in
|
||||||
let
|
let
|
||||||
# Configuration helpers
|
# Configuration helpers
|
||||||
configurationTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager"];
|
configurationTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager"];
|
||||||
|
|
||||||
|
# `pkgs` with flake's overlays
|
||||||
|
# NOTE: done here to avoid infinite recursion
|
||||||
|
pkgs' = system:
|
||||||
|
(withSystem system ({ pkgs, ... }: pkgs)).extend
|
||||||
|
(final: prev: inputs.self.packages.${system});
|
||||||
|
|
||||||
homeManagerModule = { root, system, hostname, users ? null }: {
|
homeManagerModule = { root, system, hostname, users ? null }: {
|
||||||
home-manager = {
|
home-manager = {
|
||||||
# Use same `pkgs` instance as system (i.e. carry over overlays)
|
# Use same `pkgs` instance as system (i.e. carry over overlays)
|
||||||
|
@ -24,7 +28,7 @@ let
|
||||||
sharedModules = builtins.attrValues config.flake.${configuration-type-to-outputs-modules "home-manager"};
|
sharedModules = builtins.attrValues config.flake.${configuration-type-to-outputs-modules "home-manager"};
|
||||||
# Pass in `inputs`, `outputs` and maybe `meta`
|
# Pass in `inputs`, `outputs` and maybe `meta`
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
inherit inputs outputs;
|
inherit inputs;
|
||||||
# TODO: meta?
|
# TODO: meta?
|
||||||
inherit hostname;
|
inherit hostname;
|
||||||
};
|
};
|
||||||
|
@ -42,7 +46,7 @@ let
|
||||||
|
|
||||||
mkNixosHost = args @ { root, system, hostname, users }: inputs.nixpkgs.lib.nixosSystem {
|
mkNixosHost = args @ { root, system, hostname, users }: inputs.nixpkgs.lib.nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
pkgs = withSystem system ({ pkgs, ... }: pkgs);
|
pkgs = pkgs' system;
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
# Main configuration
|
# Main configuration
|
||||||
|
@ -62,14 +66,14 @@ let
|
||||||
] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nixos"});
|
] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nixos"});
|
||||||
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit inputs outputs;
|
inherit inputs;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mkNixOnDroidHost = args @ { root, system, hostname }: inputs.nix-on-droid.lib.nixOnDroidConfiguration {
|
mkNixOnDroidHost = args @ { root, system, hostname }: inputs.nix-on-droid.lib.nixOnDroidConfiguration {
|
||||||
# NOTE: inferred by `pkgs.system`
|
# NOTE: inferred by `pkgs.system`
|
||||||
# inherit system;
|
# inherit system;
|
||||||
pkgs = withSystem system ({ pkgs, ... }: pkgs);
|
pkgs = pkgs' system;
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
# Main configuration
|
# Main configuration
|
||||||
|
@ -79,7 +83,7 @@ let
|
||||||
] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nix-on-droid"});
|
] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nix-on-droid"});
|
||||||
|
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
inherit inputs outputs;
|
inherit inputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
home-manager-path = inputs.home-manager.outPath;
|
home-manager-path = inputs.home-manager.outPath;
|
||||||
|
@ -87,7 +91,7 @@ let
|
||||||
|
|
||||||
mkNixDarwinHost = args @ { root, system, hostname, users }: inputs.nix-darwin.lib.darwinSystem {
|
mkNixDarwinHost = args @ { root, system, hostname, users }: inputs.nix-darwin.lib.darwinSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
pkgs = withSystem system ({ pkgs, ... }: pkgs);
|
pkgs = pkgs' system;
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
# Main configuration
|
# Main configuration
|
||||||
|
@ -102,20 +106,20 @@ let
|
||||||
] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nix-darwin"});
|
] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nix-darwin"});
|
||||||
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit inputs outputs;
|
inherit inputs;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mkHomeManagerHost = args @ { root, system, hostname }: inputs.home-manager.lib.homeManagerConfiguration {
|
mkHomeManagerHost = args @ { root, system, hostname }: inputs.home-manager.lib.homeManagerConfiguration {
|
||||||
inherit system;
|
inherit system;
|
||||||
pkgs = withSystem system ({ pkgs, ... }: pkgs);
|
pkgs = pkgs' system;
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
"${root}/home.nix"
|
"${root}/home.nix"
|
||||||
] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "home-manager"});
|
] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "home-manager"});
|
||||||
|
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
inherit inputs outputs;
|
inherit inputs;
|
||||||
inherit hostname;
|
inherit hostname;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -182,6 +186,20 @@ in
|
||||||
type = types.path;
|
type = types.path;
|
||||||
default = "${submodule.config.baseDir}/${configurationType}";
|
default = "${submodule.config.baseDir}/${configurationType}";
|
||||||
};
|
};
|
||||||
|
# TODO: split hosts and configurations?
|
||||||
|
resultHosts = lib.mkOption {
|
||||||
|
description = ''
|
||||||
|
The resulting automatic packages
|
||||||
|
'';
|
||||||
|
# TODO: specify
|
||||||
|
type = types.unspecified;
|
||||||
|
readOnly = true;
|
||||||
|
internal = true;
|
||||||
|
default =
|
||||||
|
lib.optionalAttrs
|
||||||
|
config.flake.autoConfigurations.${configurationType}.enable
|
||||||
|
(recurseDir config.flake.autoConfigurations.${configurationType}.dir);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -194,21 +212,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
flake = let
|
flake = {
|
||||||
autoHosts =
|
|
||||||
lib.pipe
|
|
||||||
configurationTypes
|
|
||||||
[
|
|
||||||
(builtins.map
|
|
||||||
(configurationType:
|
|
||||||
lib.nameValuePair
|
|
||||||
"${configuration-type-to-outputs-hosts configurationType}"
|
|
||||||
(if config.flake.autoConfigurations.${configurationType}.enable
|
|
||||||
then recurseDir config.flake.autoConfigurations.${configurationType}.dir
|
|
||||||
else { })))
|
|
||||||
builtins.listToAttrs
|
|
||||||
];
|
|
||||||
in autoHosts // {
|
|
||||||
# Configurations
|
# Configurations
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
createConfigurations
|
createConfigurations
|
||||||
|
@ -231,7 +235,7 @@ in
|
||||||
(lib.strings.removeSuffix ".nix")
|
(lib.strings.removeSuffix ".nix")
|
||||||
(builtins.attrNames (configurationFiles."home" or { })));
|
(builtins.attrNames (configurationFiles."home" or { })));
|
||||||
})
|
})
|
||||||
self.${configuration-type-to-outputs-hosts "nixos"};
|
config.flake.autoConfigurations.nixos.resultHosts;
|
||||||
|
|
||||||
nixOnDroidConfigurations =
|
nixOnDroidConfigurations =
|
||||||
createConfigurations
|
createConfigurations
|
||||||
|
@ -248,7 +252,7 @@ in
|
||||||
inherit system;
|
inherit system;
|
||||||
hostname = host;
|
hostname = host;
|
||||||
})
|
})
|
||||||
self.${configuration-type-to-outputs-hosts "nix-on-droid"};
|
config.flake.autoConfigurations.nix-on-droid.resultHosts;
|
||||||
|
|
||||||
darwinConfigurations =
|
darwinConfigurations =
|
||||||
createConfigurations
|
createConfigurations
|
||||||
|
@ -271,7 +275,7 @@ in
|
||||||
(lib.strings.removeSuffix ".nix")
|
(lib.strings.removeSuffix ".nix")
|
||||||
(builtins.attrNames (configurationFiles."home" or { })));
|
(builtins.attrNames (configurationFiles."home" or { })));
|
||||||
})
|
})
|
||||||
self.${configuration-type-to-outputs-hosts "nix-darwin"};
|
config.flake.autoConfigurations.nix-darwin.resultHosts;
|
||||||
|
|
||||||
homeConfigurations =
|
homeConfigurations =
|
||||||
createConfigurations
|
createConfigurations
|
||||||
|
@ -288,7 +292,7 @@ in
|
||||||
inherit system;
|
inherit system;
|
||||||
hostname = host;
|
hostname = host;
|
||||||
})
|
})
|
||||||
self.${configuration-type-to-outputs-hosts "home-manager"};
|
config.flake.autoConfigurations.home-manager.resultHosts;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ lib, config, self, inputs, ... }:
|
{ lib, config, self, inputs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (import ../../nix/utils.nix { inherit lib self; })
|
inherit (import ../../nix/utils.nix { inherit lib config self; })
|
||||||
accumulateHosts
|
accumulateHosts
|
||||||
configuration-type-to-deploy-type;
|
configuration-type-to-deploy-type;
|
||||||
in
|
in
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
{ lib, config, self, inputs, ... }:
|
{ lib, config, self, inputs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
outputs = self;
|
inherit (import ../../nix/utils.nix { inherit lib config self; })
|
||||||
inherit (import ../../nix/utils.nix { inherit lib self; })
|
|
||||||
eq
|
eq
|
||||||
and
|
and
|
||||||
hasFiles
|
hasFiles
|
||||||
|
@ -12,7 +11,7 @@ let
|
||||||
# Modules helpers
|
# Modules helpers
|
||||||
moduleTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager" "flake"];
|
moduleTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager" "flake"];
|
||||||
|
|
||||||
createModules = baseDir: { passthru ? { inherit inputs outputs; }, ... }:
|
createModules = baseDir: { passthru ? { inherit inputs; }, ... }:
|
||||||
lib.pipe baseDir [
|
lib.pipe baseDir [
|
||||||
# Read given directory
|
# Read given directory
|
||||||
builtins.readDir
|
builtins.readDir
|
||||||
|
@ -55,6 +54,7 @@ let
|
||||||
if and [
|
if and [
|
||||||
(builtins.isFunction
|
(builtins.isFunction
|
||||||
module)
|
module)
|
||||||
|
# FIXME: check for subset, not `eq`
|
||||||
(eq
|
(eq
|
||||||
(lib.pipe module [ builtins.functionArgs builtins.attrNames ])
|
(lib.pipe module [ builtins.functionArgs builtins.attrNames ])
|
||||||
(lib.pipe passthru [ builtins.attrNames ]))
|
(lib.pipe passthru [ builtins.attrNames ]))
|
||||||
|
@ -104,6 +104,19 @@ in
|
||||||
type = types.path;
|
type = types.path;
|
||||||
default = "${submodule.config.baseDir}/${moduleType}";
|
default = "${submodule.config.baseDir}/${moduleType}";
|
||||||
};
|
};
|
||||||
|
result = lib.mkOption {
|
||||||
|
description = ''
|
||||||
|
The resulting automatic packages
|
||||||
|
'';
|
||||||
|
# TODO: specify
|
||||||
|
type = types.unspecified;
|
||||||
|
readOnly = true;
|
||||||
|
internal = true;
|
||||||
|
default =
|
||||||
|
lib.optionalAttrs
|
||||||
|
config.flake.autoModules.${moduleType}.enable
|
||||||
|
(createModules config.flake.autoModules.${moduleType}.dir { });
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -123,22 +136,13 @@ in
|
||||||
[
|
[
|
||||||
(builtins.map
|
(builtins.map
|
||||||
(moduleType:
|
(moduleType:
|
||||||
lib.nameValuePair
|
let
|
||||||
"${configuration-type-to-outputs-modules moduleType}"
|
name = "${configuration-type-to-outputs-modules moduleType}";
|
||||||
(if config.flake.autoModules.${moduleType}.enable
|
value = config.flake.autoModules.${moduleType}.result;
|
||||||
then createModules config.flake.autoModules.${moduleType}.dir { }
|
in
|
||||||
else { })))
|
lib.nameValuePair name value))
|
||||||
builtins.listToAttrs
|
builtins.listToAttrs
|
||||||
];
|
];
|
||||||
in {
|
in autoModules;
|
||||||
# NOTE: manually inheriting generated modules to avoid recursion
|
|
||||||
# (`autoModules` depends on `config.flake` itself)
|
|
||||||
inherit (autoModules)
|
|
||||||
nixosModules
|
|
||||||
nixOnDroidModules
|
|
||||||
darwinModules
|
|
||||||
homeManagerModules
|
|
||||||
flakeModules;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
129
modules/flake/packages/default.nix
Normal file
129
modules/flake/packages/default.nix
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
{ lib, config, self, inputs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (import ../../../nix/utils.nix { inherit lib config self; })
|
||||||
|
eq
|
||||||
|
and
|
||||||
|
hasFiles;
|
||||||
|
in
|
||||||
|
let
|
||||||
|
createPackages = baseDir: { passthru ? { inherit inputs; }, ... }:
|
||||||
|
lib.pipe baseDir [
|
||||||
|
# Read given directory
|
||||||
|
builtins.readDir
|
||||||
|
# Map each entry to a package
|
||||||
|
(lib.mapAttrs'
|
||||||
|
(name: type:
|
||||||
|
let
|
||||||
|
packageDir = "${baseDir}/${name}";
|
||||||
|
systems = let
|
||||||
|
systemsPath = "${baseDir}/${name}/systems.nix";
|
||||||
|
in
|
||||||
|
# NOTE: If the package can restrict for which systems it wants to be built
|
||||||
|
if builtins.pathExists systemsPath
|
||||||
|
then import systemsPath
|
||||||
|
else lib.const true;
|
||||||
|
package = import packageDir;
|
||||||
|
result = {
|
||||||
|
inherit package systems;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
if and [
|
||||||
|
(type == "directory")
|
||||||
|
(hasFiles [ "default.nix" ] (builtins.readDir packageDir))
|
||||||
|
] then
|
||||||
|
# NOTE: Classic package in a directory
|
||||||
|
lib.nameValuePair
|
||||||
|
name
|
||||||
|
result
|
||||||
|
else if and [
|
||||||
|
(type == "regular")
|
||||||
|
(lib.hasSuffix ".nix" name)
|
||||||
|
] then
|
||||||
|
# NOTE: Classic package in a file
|
||||||
|
lib.nameValuePair
|
||||||
|
(lib.removeSuffix ".nix" name)
|
||||||
|
result
|
||||||
|
else
|
||||||
|
# NOTE: Invalid package
|
||||||
|
lib.nameValuePair
|
||||||
|
name
|
||||||
|
null))
|
||||||
|
# Filter invalid packages
|
||||||
|
(lib.filterAttrs
|
||||||
|
(packageName: package:
|
||||||
|
package != null))
|
||||||
|
# Passthru if needed
|
||||||
|
(lib.mapAttrs
|
||||||
|
(packageName: package:
|
||||||
|
if and [
|
||||||
|
(builtins.isFunction
|
||||||
|
package)
|
||||||
|
(eq
|
||||||
|
(lib.pipe package [ builtins.functionArgs builtins.attrNames ])
|
||||||
|
(lib.pipe passthru [ builtins.attrNames ]))
|
||||||
|
]
|
||||||
|
then package passthru
|
||||||
|
else package))
|
||||||
|
];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = let
|
||||||
|
inherit (lib) types;
|
||||||
|
in {
|
||||||
|
flake.autoPackages = lib.mkOption {
|
||||||
|
description = ''
|
||||||
|
Automagically generate packages from walking directories with Nix files
|
||||||
|
'';
|
||||||
|
type = types.submodule (submodule: {
|
||||||
|
options = {
|
||||||
|
enable = lib.mkEnableOption "Automatic packages extraction";
|
||||||
|
dir = lib.mkOption {
|
||||||
|
description = ''
|
||||||
|
Base directory of the contained packages
|
||||||
|
'';
|
||||||
|
type = types.path;
|
||||||
|
default = "${self}/pkgs";
|
||||||
|
defaultText = ''''${self}/pkgs'';
|
||||||
|
};
|
||||||
|
result = lib.mkOption {
|
||||||
|
description = ''
|
||||||
|
The resulting automatic packages
|
||||||
|
'';
|
||||||
|
type = types.attrsOf (types.submodule { options = {
|
||||||
|
package = lib.mkOption { type = types.unspecified; };
|
||||||
|
systems = lib.mkOption { type = types.functionTo types.bool; };
|
||||||
|
};});
|
||||||
|
readOnly = true;
|
||||||
|
internal = true;
|
||||||
|
default =
|
||||||
|
lib.optionalAttrs
|
||||||
|
config.flake.autoPackages.enable
|
||||||
|
(createPackages config.flake.autoPackages.dir { });
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
perSystem = { lib, pkgs, system, ... }: let
|
||||||
|
packages =
|
||||||
|
lib.pipe
|
||||||
|
config.flake.autoPackages.result
|
||||||
|
[
|
||||||
|
(lib.filterAttrs
|
||||||
|
(name: { package, systems }:
|
||||||
|
pkgs.callPackage systems {
|
||||||
|
inherit (pkgs) lib hostPlatform targetPlatform;
|
||||||
|
}))
|
||||||
|
(lib.mapAttrs
|
||||||
|
(name: { package, systems }:
|
||||||
|
pkgs.callPackage package { }))
|
||||||
|
];
|
||||||
|
in {
|
||||||
|
inherit packages;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,6 +4,8 @@
|
||||||
perSystem = { system, ... }: {
|
perSystem = { system, ... }: {
|
||||||
_module.args.pkgs = import inputs.nixpkgs {
|
_module.args.pkgs = import inputs.nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
# WARN: not including `self.packages` overylay
|
||||||
|
# because it causes an infinite recursion
|
||||||
overlays = lib.attrValues self.overlays ++ [
|
overlays = lib.attrValues self.overlays ++ [
|
||||||
inputs.neovim-nightly-overlay.overlays.default
|
inputs.neovim-nightly-overlay.overlays.default
|
||||||
inputs.zig-overlay.overlays.default
|
inputs.zig-overlay.overlays.default
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, ... }:
|
{ inputs, ... }:
|
||||||
{ lib, pkgs, config, ... }:
|
{ lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, ... }:
|
{ inputs, ... }:
|
||||||
{ lib, pkgs, config, ... }:
|
{ lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
#
|
#
|
||||||
# # Use flake overlays by default
|
# # Use flake overlays by default
|
||||||
# nixpkgs = {
|
# nixpkgs = {
|
||||||
# overlays = lib.attrValues outputs.overlays;
|
# overlays = lib.attrValues inputs.self.overlays;
|
||||||
#
|
#
|
||||||
# config.allowUnfree = true;
|
# config.allowUnfree = true;
|
||||||
# };
|
# };
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, ... }:
|
{ inputs, ... }:
|
||||||
{ lib, pkgs, config, ... }:
|
{ lib, pkgs, config, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, ... }:
|
{ inputs, ... }:
|
||||||
{ lib, pkgs, config, ... }:
|
{ lib, pkgs, config, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, outputs, lib, pkgs, config, options, ... }:
|
{ inputs, lib, pkgs, config, options, ... }:
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
# NOTE: `(r)agenix` and `agenix-rekey` modules are imported by `../../../modules/flake/configurations.nix`
|
# NOTE: `(r)agenix` and `agenix-rekey` modules are imported by `../../../modules/flake/configurations.nix`
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, self, ... }:
|
{ lib, config, self, ... }:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
# Boolean helpers
|
# Boolean helpers
|
||||||
|
@ -109,10 +109,7 @@ rec {
|
||||||
(lib.genAttrs
|
(lib.genAttrs
|
||||||
configuration-types
|
configuration-types
|
||||||
(configuration-type:
|
(configuration-type:
|
||||||
let
|
config.flake.autoConfigurations.${configuration-type}.resultHosts))
|
||||||
hosts = configuration-type-to-outputs-hosts configuration-type;
|
|
||||||
in
|
|
||||||
self.${hosts}))
|
|
||||||
(configuration-type: hosts:
|
(configuration-type: hosts:
|
||||||
lib.pipe
|
lib.pipe
|
||||||
hosts
|
hosts
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
# This file defines overlays
|
# This file defines overlays
|
||||||
{ inputs, ... }:
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
# This one brings our custom packages from the 'pkgs' directory
|
# This one brings our custom packages
|
||||||
additions = final: _prev: import ../pkgs {
|
# BUG: causes infinite recursion
|
||||||
pkgs = final;
|
# additions = final: prev: inputs.self.packages.${prev.system};
|
||||||
};
|
|
||||||
|
|
||||||
# This one contains whatever you want to overlay
|
# This one contains whatever you want to overlay
|
||||||
# You can change versions, add patches, set compilation flags, anything really.
|
# You can change versions, add patches, set compilation flags, anything really.
|
||||||
|
@ -30,7 +29,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nix-monitored = inputs.nix-monitored.packages.${final.system}.default.override {
|
nix-monitored = inputs.nix-monitored.packages.${prev.system}.default.override {
|
||||||
nix = prev.nix;
|
nix = prev.nix;
|
||||||
nix-output-monitor = prev.nix-output-monitor;
|
nix-output-monitor = prev.nix-output-monitor;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
# Custom packages, that can be defined similarly to ones from nixpkgs
|
|
||||||
# You can build them using 'nix build .#example' or (legacy) 'nix-build -A example'
|
|
||||||
|
|
||||||
{ pkgs ? (import ../nixpkgs.nix) { }
|
|
||||||
, ...
|
|
||||||
}: {
|
|
||||||
# example = pkgs.callPackage ./example { };
|
|
||||||
advcpmv = pkgs.callPackage ./advcpmv { };
|
|
||||||
circom = pkgs.callPackage ./circom { };
|
|
||||||
circom-lsp = pkgs.callPackage ./circom-lsp { };
|
|
||||||
envsub = pkgs.callPackage ./envsub { };
|
|
||||||
fennel-language-server = pkgs.callPackage ./fennel-language-server { };
|
|
||||||
flamelens = pkgs.callPackage ./flamelens { };
|
|
||||||
parinfer-rust = pkgs.callPackage ./parinfer-rust { };
|
|
||||||
pest-ide-tools = pkgs.callPackage ./pest-ide-tools { };
|
|
||||||
# FIXME: only buildable on darwin
|
|
||||||
# pngpaste = pkgs.callPackage ./pngpaste { };
|
|
||||||
srtool-cli = pkgs.callPackage ./srtool-cli { };
|
|
||||||
# FIXME: does not build
|
|
||||||
# swww = pkgs.callPackage ./swww { };
|
|
||||||
vim-fmi-cli = pkgs.callPackage ./vim-fmi-cli { };
|
|
||||||
win2xcur = pkgs.callPackage ./win2xcur { };
|
|
||||||
}
|
|
2
pkgs/pngpaste/systems.nix
Normal file
2
pkgs/pngpaste/systems.nix
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{ lib, hostPlatform, targetPlatform, ... }:
|
||||||
|
targetPlatform.isDarwin
|
3
pkgs/swww/systems.nix
Normal file
3
pkgs/swww/systems.nix
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{ lib, hostPlatform, targetPlatform, ... }:
|
||||||
|
# BUG: does not build
|
||||||
|
false
|
Loading…
Reference in a new issue