Flake Experiment
This commit is contained in:
20
Makefile
20
Makefile
@@ -3,6 +3,7 @@
|
||||
NIXOS_DIR := /etc/nixos
|
||||
REPO_DIR := $(shell pwd)
|
||||
SETTINGS := settings.nix
|
||||
HOSTNAME := $(shell grep 'hostname =' $(SETTINGS) | cut -d '"' -f 2)
|
||||
|
||||
# Colors for output
|
||||
GREEN := \033[0;32m
|
||||
@@ -11,12 +12,12 @@ RED := \033[0;31m
|
||||
NC := \033[0m # No Color
|
||||
|
||||
help:
|
||||
@echo "NixOS Config"
|
||||
@echo "NixOS Config (Flake)"
|
||||
@echo ""
|
||||
@echo " make init - first time setup"
|
||||
@echo " make hw - generate hardware-configuration.nix"
|
||||
@echo " make rebuild - rebuild nixos"
|
||||
@echo " make update - upgrade + rebuild"
|
||||
@echo " make rebuild - rebuild nixos configuration"
|
||||
@echo " make update - update flake inputs and rebuild"
|
||||
@echo " make purge - garbage collect"
|
||||
@echo " make link - symlink to /etc/nixos"
|
||||
@echo " make unlink - remove symlink"
|
||||
@@ -48,17 +49,24 @@ unlink:
|
||||
fi
|
||||
|
||||
rebuild:
|
||||
sudo nixos-rebuild switch
|
||||
@# Ensure hardware-configuration.nix is tracked by git (flake requirement), even if ignored
|
||||
@if [ -f hardware-configuration.nix ]; then \
|
||||
git add -f -N hardware-configuration.nix; \
|
||||
fi
|
||||
@echo "Rebuilding system for $(HOSTNAME)..."
|
||||
sudo nixos-rebuild switch --flake .#$(HOSTNAME)
|
||||
|
||||
update:
|
||||
sudo nixos-rebuild switch --upgrade
|
||||
@echo "Updating flake inputs..."
|
||||
nix flake update
|
||||
@$(MAKE) --no-print-directory rebuild
|
||||
|
||||
purge:
|
||||
sudo nix-collect-garbage -d
|
||||
sudo /run/current-system/bin/switch-to-configuration boot
|
||||
|
||||
check:
|
||||
nix-instantiate '<nixpkgs/nixos>' -A system --dry-run
|
||||
nix flake check
|
||||
|
||||
hw:
|
||||
sudo nixos-generate-config --show-hardware-config > hardware-configuration.nix
|
||||
|
||||
22
common.nix
Normal file
22
common.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
# Import Modules
|
||||
./modules/boot.nix
|
||||
./modules/networking.nix
|
||||
./modules/locale.nix
|
||||
./modules/desktop.nix
|
||||
./modules/audio.nix
|
||||
./modules/users.nix
|
||||
./modules/programs.nix
|
||||
./modules/hardware.nix
|
||||
./modules/services.nix
|
||||
./modules/home.nix
|
||||
];
|
||||
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
# xdg.portal.config.common.default = [ "gnome" ];
|
||||
|
||||
system.stateVersion = "25.11";
|
||||
}
|
||||
26
flake.nix
Normal file
26
flake.nix
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
description = "NixOS Configuration";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager/release-25.11";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, home-manager, ... }@inputs:
|
||||
let
|
||||
settings = import ./settings.nix;
|
||||
system = "x86_64-linux";
|
||||
in {
|
||||
nixosConfigurations."${settings.hostname}" = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
./configuration.nix
|
||||
home-manager.nixosModules.home-manager
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-25.11.tar.gz";
|
||||
settings = import ../settings.nix;
|
||||
homeModules = [
|
||||
./home/session.nix
|
||||
@@ -16,10 +15,6 @@ let
|
||||
];
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(import "${home-manager}/nixos")
|
||||
];
|
||||
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user