summaryrefslogtreecommitdiffstats
path: root/flake.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-10-30 14:26:34 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-10-30 14:26:34 +0100
commit981060cf79e468da091b7bb359d19e514fa23ab1 (patch)
treeb900fec93ee6524e49c12f52c5003b128fbb10e6 /flake.nix
parentnotes/deploy: Add a very basic version of a deploy guide (diff)
downloadnixos-config-981060cf79e468da091b7bb359d19e514fa23ab1.zip
treewide: Align files with the same files in the `nixos-server` repo
This facilitates overlaying the two repos over each other.
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix184
1 files changed, 108 insertions, 76 deletions
diff --git a/flake.nix b/flake.nix
index a63e03b2..9e306ef7 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,104 +1,136 @@
-# nixos-config - My current NixOS configuration
-#
-# Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
-# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# This file is part of my nixos-config.
-#
-# You should have received a copy of the License along with this program.
-# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
- description = "A NixOS System Configuration";
+ description = "A NixOS Configuration";
inputs = {};
outputs = {self, ...}: let
- sources = import ./unflake.nix;
-
- # core
- nixpkgs = sources.nixpkgs;
- nixpkgs-stable = sources.nixpkgs-stable;
- library = sources.library;
- # modules
- home-manager = sources.home-manager;
- nixos-generators = sources.nixos-generators;
- impermanence = sources.impermanence;
- agenix = sources.agenix;
- serverphone = sources.serverphone;
- disko = sources.disko;
- lanzaboote = sources.lanzaboote;
- nixvim = sources.nixvim;
- nix-index-database = sources.nix-index-database;
- # external dependencies
- treefmt-nix = sources.treefmt-nix;
- templates = sources.templates;
- # my binaries
- qmk_firmware = sources.qmk_firmware;
- turtle = sources.turtle;
+ raw_sources = import ./unflake.nix;
system = "x86_64-linux";
+ # Filter out the nixpkgs's from the sources, so we always use the `packageSets`.
+ sources = builtins.removeAttrs raw_sources ["nixpkgs-stable" "nixpkgs-unstable" "library"];
+
packageSets = rec {
- stable = nixpkgs-stable.legacyPackages.${system};
- unstable = nixpkgs.legacyPackages.${system};
+ stable = raw_sources.nixpkgs-stable.legacyPackages.${system};
+ unstable = raw_sources.nixpkgs-unstable.legacyPackages.${system};
- soispha = import ./pkgs {
- inherit libraries;
- pkgs = unstable;
+ in_tree = import ./pkgs {
+ unstable_pkgs = unstable;
+ stable_pkgs = stable;
+ inherit extra_lib;
};
};
+ lib = packageSets.unstable.lib;
+ extra_lib = raw_sources.library.nixLib;
- libraries = rec {
- nix = packageSets.unstable.lib;
- base = import ./lib {lib = nix;};
- extra = library.nixLib;
- };
-
- modules = {
- inherit
- home-manager
- nixvim
- nixos-generators
- impermanence
- agenix
- serverphone
- disko
- lanzaboote
- nix-index-database
- ;
- };
-
- externalDependencies = {
+ extra_modules = [
+ sources.agenix.nixosModules.default
+ sources.turtle.nixosModules.nixos
+ sources.disko.nixosModules.default
+ sources.impermanence.nixosModules.impermanence
+ sources.simple-nixos-mailserver.nixosModule
+ sources.rocie.nixosModules.default
+ ];
+ module_args = {
inherit
- treefmt-nix
- templates
+ sources
+ # extra package sources
+ openPRsNixpkgs
+ packageSets
+ # extra information
+ system
;
};
-
- externalBinaries = {
+ special_args = {
inherit
- qmk_firmware
- turtle
+ self
+ # Needs to be a special argument, because it is used for determining the `imports`
+ # value (via `mkByName`).
+ extra_lib
;
};
openPRsNixpkgs = {};
- outputs = import ./flake {
+ treefmtEval = import ./treefmt.nix {
+ inherit (sources) treefmt-nix;
+ pkgs = packageSets.unstable;
+ };
+
+ hosts = import ./hosts {
inherit
self
- sources
- nixpkgs
+ extra_lib
+ module_args
+ special_args
+ extra_modules
system
- openPRsNixpkgs
- packageSets
- libraries
- modules
- externalDependencies
- externalBinaries
+ ;
+ inherit
+ (raw_sources)
+ nixpkgs-unstable
+ nixpkgs-stable
+ deploy-rs
;
};
- in
- outputs;
+
+ deployChecks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) sources.deploy-rs.lib;
+ tests = lib.attrsets.filterAttrs (_: v: !(v ? meta && v.meta.broken)) (import ./tests
+ {
+ inherit sources packageSets extra_modules module_args special_args extra_lib;
+ });
+ # myPkgsFlat =
+ # builtins.listToAttrs
+ # # Filter out the `override` and `overrideDerivation` functions
+ # (builtins.filter
+ # ({ name, value, }: lib.attrsets.isDerivation value)
+ # (lib.lists.flatten
+ # (lib.attrsets.mapAttrsToList
+ # (name: value:
+ # if lib.attrsets.isDerivation value then
+ # [ { inherit name value; } ]
+ # else
+ # lib.attrsets.mapAttrsToList
+ # (name: value: { inherit name value; })
+ # value
+ # )
+ # packageSets.in_tree
+ # )
+ # )
+ # );
+ in {
+ checks."${system}" =
+ extra_lib.warnMerge
+ deployChecks."${system}"
+ (extra_lib.warnMerge
+ tests
+ {formatting = treefmtEval.config.build.check self;}
+ "the flake checks and formatting")
+ "the flake checks and deploy rs checks";
+
+ legacyPackages."${system}" = packageSets.unstable;
+
+ packages."${system}" = packageSets.in_tree;
+
+ formatter."${system}" = treefmtEval.config.build.wrapper;
+
+ devShells."${system}" = {
+ default = packageSets.unstable.mkShell {
+ packages = [
+ packageSets.unstable.deploy-rs
+
+ # Used to update the stalwart-mail spamfilter
+ packageSets.unstable.nix-update
+
+ (sources.agenix.packages."${system}".default.override {
+ nix = packageSets.unstable.lixPackageSets.latest.lix;
+ })
+ ];
+ };
+ };
+
+ deploy.nodes = hosts.nodes;
+ inherit (hosts) nixosConfigurations;
+ };
}