nixconfigs/flake.nix
Trolli Schmittlauch d95c277383 flake: nixpkgs 24.11 -> 25.05, relock all inputs
Flake lock file updates:

• Updated input 'home-manager':
    'github:nix-community/home-manager/b4bbdc6fde16fc2051fcde232f6e288cd22007ca' (2025-05-12)
  → 'github:nix-community/home-manager/d0bbd221482c2713cccb80220f3c9d16a6e20a33' (2025-05-18)
• Updated input 'nix-darwin':
    'github:LnL7/nix-darwin/fc843893cecc1838a59713ee3e50e9e7edc6207c' (2025-03-28)
  → 'github:LnL7/nix-darwin/74ecd01d2c122f8a4a48066ab1d48f3e01671671' (2025-05-20)
• Updated input 'nixos-hardware':
    'github:NixOS/nixos-hardware/e81fd167b33121269149c57806599045fd33eeed' (2025-05-13)
  → 'github:NixOS/nixos-hardware/6ac6ec6fcb410e15a60ef5ec94b8a2b35b5dd282' (2025-05-20)
• Updated input 'nixos-unstable':
    'github:NixOS/nixpkgs/d89fc19e405cb2d55ce7cc114356846a0ee5e956' (2025-05-10)
  → 'github:NixOS/nixpkgs/292fa7d4f6519c074f0a50394dbbe69859bb6043' (2025-05-18)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/a39ed32a651fdee6842ec930761e31d1f242cb94' (2025-05-11)
  → 'github:NixOS/nixpkgs/ca49c4304acf0973078db0a9d200fd2bae75676d' (2025-05-18)
• Updated input 'nur':
    'github:nix-community/NUR/e29c558fa4174da179e2e7f9a41c34466a200fda' (2025-05-14)
  → 'github:nix-community/NUR/e52a85ce10a990ac6d7356f3a753fde0860426a8' (2025-05-20)
• Updated input 'nur/nixpkgs':
    'github:nixos/nixpkgs/d89fc19e405cb2d55ce7cc114356846a0ee5e956' (2025-05-10)
  → 'github:nixos/nixpkgs/292fa7d4f6519c074f0a50394dbbe69859bb6043' (2025-05-18)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/29ec5026372e0dec56f890e50dbe4f45930320fd' (2025-05-02)
  → 'github:numtide/treefmt-nix/ab0378b61b0d85e73a8ab05d5c6029b5bd58c9fb' (2025-05-17)
2025-05-20 18:55:22 +02:00

198 lines
6.2 KiB
Nix

{
description = "NixOS system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
home-manager = {
url = "github:nix-community/home-manager/release-25.05";
inputs.nixpkgs.follows = "nixpkgs";
};
lanzaboote = {
url = "github:nix-community/lanzaboote/v0.4.2";
# deliberately do _not_ follow the nixpkgs input here, because paranoia and test coverage
};
utils.url = "github:numtide/flake-utils";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-darwin = {
url = "github:LnL7/nix-darwin/nix-darwin-25.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nur.url = "github:nix-community/NUR";
# TODO: possible make this a flake as well
mysecrets = {
flake = false;
url = "git+ssh://gitea@git.orlives.de:2342/schmittlauch/home-manager_secrets.git";
};
};
outputs =
{
self,
nixpkgs,
nur,
lanzaboote,
utils,
home-manager,
treefmt-nix,
nix-darwin,
...
}@inputs:
let
# FIXME: allow different systems
systems = utils.lib.system;
# necessary to make the top-level inputs available to system configuration
# inspired by https://jade.fyi/blog/flakes-arent-real/
inputInjection =
{ pkgs, lib, ... }:
{
options.inputInjection = lib.mkOption {
type = with lib.types; attrsOf unspecified;
default = { };
};
config.inputInjection = {
flake-inputs = inputs;
};
};
defaultModules = system: [
inputInjection
# for some reason, `imports`-ing the home-manager module via inputInjection
# from a sub-module causes infinite recursion, so importing it here instead
home-manager.nixosModules.home-manager
];
mkSystem =
system: extraModules:
nixpkgs.lib.nixosSystem rec {
modules = (defaultModules system) ++ extraModules;
inherit system;
specialArgs = {
inherit system;
};
};
mkHomeManager =
confName: user: system: # unfortunately, home-manager configs are still system-specific
home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
modules = [
{
imports = [
./home/common.nix
./home/${confName}.nix
];
# extends the home config
home.username = user;
}
];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
extraSpecialArgs = {
inherit inputs system;
};
};
treefmtConf =
{ pkgs, ... }:
{
projectRootFile = "flake.nix";
programs.nixfmt.enable = true;
};
in
{
overlays.default = import ./packages;
nixosConfigurations = {
thinknix = mkSystem systems.x86_64-linux [
./hosts/thinknix
inputs.nixos-hardware.nixosModules.lenovo-thinkpad-t440s
lanzaboote.nixosModules.lanzaboote
];
framenix = mkSystem systems.x86_64-linux [
./hosts/framenix
inputs.nixos-hardware.nixosModules.framework-13-7040-amd
lanzaboote.nixosModules.lanzaboote
];
};
darwinConfigurations."OS-MacBook-Pro" = nix-darwin.lib.darwinSystem {
modules = [
./darwin/configuration.nix
inputInjection
];
};
homeConfigurations = {
spiollinux-desktop = mkHomeManager "desktop" "spiollinux" systems.x86_64-linux;
os-workmac = mkHomeManager "workmac" "os" systems.aarch64-darwin;
};
lib = {
inherit mkHomeManager;
};
}
// utils.lib.eachDefaultSystem (
system:
let
nixpkgs = import inputs.nixpkgs {
inherit system;
overlays = nixpkgs.lib.attrValues self.overlays;
};
nixpkgs_unstable = import inputs.nixos-unstable {
inherit system;
overlays = nixpkgs.lib.attrValues self.overlays;
};
pkgs = inputs.nixpkgs.legacyPackages.${system};
pkgs_unstable = inputs.nixos-unstable.legacyPackages.${system};
treefmtEval = treefmt-nix.lib.evalModule pkgs_unstable treefmtConf;
in
{
devShells.default = pkgs.mkShell { buildInputs = [ ]; };
formatter = treefmtEval.config.build.wrapper;
checks.formatting = treefmtEval.config.build.check self;
# expose nixpkgs with overlay; TODO: figure out role of config
#legacyPackages = nixpkgs;
# inspired by https://github.com/Mic92/dotfiles/blob/main/home-manager/flake-module.nix
# run like: `nix run .#hm -- <action>`
apps.hm = {
type = "app";
program = "${pkgs.writeShellScriptBin "hm" ''
set -x
export PATH=${
pkgs.lib.makeBinPath [
pkgs.git
pkgs.coreutils
pkgs.findutils
pkgs.lix
pkgs.jq
pkgs.unixtools.hostname
]
}
declare -A profiles=(
["framenix"]="spiollinux-desktop"
["thinknix"]="spiollinux-desktop"
["OS MacBook Pro"]="os-workmac"
)
user=$(id -un)
host=$(hostname)
if [[ -n ''${profiles["$host-$user"]} ]]; then
profile=''${profiles["$host-$user"]};
elif [[ -n ''${profiles[$host]:-} ]]; then
profile=''${profiles[$host]}
else
echo "No suitable profile found." >2
exit 2
fi
if [[ "''${1:-}" == profile ]]; then
echo $profile
exit 0
fi
${
inputs.home-manager.packages.${pkgs.system}.home-manager
}/bin/home-manager --flake "${self}#$profile" "$@"
''}/bin/hm";
};
}
);
}