add initial nixos mylib
This commit is contained in:
5
lib/default.nix
Normal file
5
lib/default.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{ inputs, pkgs, lib, ... }:
|
||||
|
||||
rec {
|
||||
nixos = import ./nixos.nix;
|
||||
}
|
47
lib/nixos.nix
Normal file
47
lib/nixos.nix
Normal file
@ -0,0 +1,47 @@
|
||||
{ inputs, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
# Allows to just use nixpkgs without qualifiers
|
||||
inherit (inputs) nixpkgs;
|
||||
|
||||
in rec {
|
||||
mkNixosConfig = { system, hostname, extraModules, homeManagerConfig }:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
|
||||
# Make our inputs available to the configuration.nix (for importing modules)
|
||||
specialArgs = { inherit inputs; };
|
||||
|
||||
modules = builtins.conatLists [
|
||||
[
|
||||
# Replace the pkgs to include overlays/unfree
|
||||
{ nixpkgs.pkgs = pkgs; }
|
||||
|
||||
# Main config file for all configs/hosts
|
||||
./nixos/configuration.nix
|
||||
|
||||
# Host specifig config file
|
||||
(import "./nixos/configuration-" + hostname + ".nix")
|
||||
]
|
||||
extraModules
|
||||
homeManagerConfig
|
||||
];
|
||||
};
|
||||
|
||||
mkHomeManagerConfig = { username }:
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
# Use systems pkgs, disables nixpkgs.* options in home.nix
|
||||
home-manager.useGlobalPkgs = true;
|
||||
|
||||
# Enable installing packages through users.christoph.packages to /etc/profiles instead of ~/.nix-profile
|
||||
home-manager.useUserPackages = true;
|
||||
|
||||
# User specific config file
|
||||
home-manager.users.username = import "./home/home-" + username + ".nix";
|
||||
|
||||
# Include the inputs just in case they might be needed somewhere
|
||||
home-manager.extraSpecialArgs = { inherit inputs; };
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user