You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
server/flake.nix

109 lines
3.2 KiB
Nix

3 months ago
{
description = "banananet.work Server & Deployment Controller environment";
inputs = {
# packages repositories
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs_unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# required submodules
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
3 months ago
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
3 months ago
inputs.nixpkgs.follows = "nixpkgs";
};
impermanence.url = "github:nix-community/impermanence";
secrix = {
# TODO revert after my pulls are merged: https://github.com/Platonic-Systems/secrix/pulls/Zocker1999NET
#url = "github:Platonic-Systems/secrix";
url = "github:Zocker1999NET/secrix/release-bnet";
inputs.nixpkgs.follows = "nixpkgs";
};
3 months ago
# required for configs
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
unattended-installer = {
url = "github:chrillefkr/nixos-unattended-installer";
inputs.disko.follows = "disko";
inputs.nixpkgs.follows = "nixpkgs";
};
# TODO experiment with
# - https://git.sr.ht/~msalerno/wirenix
3 months ago
};
outputs =
{ self, ... }@inputs:
3 months ago
let
inherit (self) outputs;
2 months ago
inherit (outputs) lib;
# every flake "submodule" gets this passed:
flakeArg = {
# Usage in submodule:
# { ... }@flakeArg: { }
# add "..." this so new ones can easily be added
inherit
2 months ago
# tools / shortcuts
lib # nixpkgs & my lib combined
# flake refs
inputs # evaluated inputs
outputs # evaluated outputs
;
# self: the modules result, via self-reflection
};
importFlakeMod = path: outputs.libAnchors.reflect (import path) flakeArg;
importFlakeModWithSystem = path: lib.forAllSystems (importFlakeMod path);
3 months ago
in
{
apps = importFlakeModWithSystem ./nix/apps;
devShells = importFlakeModWithSystem ./nix/devShells;
homeManagerModules = importFlakeMod ./nix/hmModules;
lib = outputs.libAnchors // importFlakeMod ./nix/lib;
# anchors required for importing modules
libAnchors =
let
lib = inputs.nixpkgs.lib;
inherit (lib.asserts) assertMsg;
in
{
# ({?} -> ?) -> {?} -> ?
# gives a function access to its own return value
# by adding it to its first argument (assuming thats an attrset)
reflect =
fun: attrs:
# TODO is there a more official way?
assert assertMsg (builtins.isAttrs attrs) ''
expected a set, got an ${builtins.typeOf attrs}
'';
assert assertMsg (!attrs ? "self") ''
reflect argument already contains a self attribute
'';
let
outputs = fun (attrs // { self = result; });
result = outputs;
in
result;
};
2 months ago
nixosConfigurations = importFlakeMod ./nix/nixos;
nixosModules = importFlakeMod ./nix/nixos-modules;
overlays = importFlakeMod ./nix/overlays;
packages = importFlakeModWithSystem ./nix/packages;
3 months ago
};
}