1

Nixos: Config overhaul + cleanup

This commit is contained in:
2024-10-11 19:55:02 +02:00
parent de686ede96
commit c8442a838b
8 changed files with 106 additions and 141 deletions

View File

@ -3,16 +3,10 @@
pkgs, pkgs,
... ...
}: { }: {
# vital-synth = pkgs.callPackage ./vital-synth {}; # Kept as an example, don't know if I will fix this or keep using distrho # I am currently not using any custom derivations.
# adwaita-for-steam = pkgs.callPackage ./adwaita-for-steam {src = inputs.adwaita-for-steam;}; # Old derivations are still kept in this folder, for reference.
# dconf-editor-wrapped = pkgs.callPackage ./dconf-editor-wrapped {};
# modules-options-doc = pkgs.callPackage ./modules-options-doc {mylib = mylib;}; # TODO: Borked
# spotdl-4_1_6 = pkgs.callPackage ./spotdl-4_1_6 {}; # TODO: Old
# wiiu-downloader = pkgs.callPackage ./wiiu-downloader {};
# TODO: Those were enabled, but have to be rewritten for standalone HM # modules-options-doc = pkgs.callPackage ./modules-options-doc {mylib = mylib;};
# dell-b1160w = pkgs.callPackage ./dell-b1160w {};
# firefox-gnome-theme = pkgs.callPackage ./firefox-gnome-theme {src = inputs.firefox-gnome-theme;};
# xdg-desktop-portal-termfilechooser = pkgs.callPackage ./xdg-desktop-portal-termfilechooser {}; # xdg-desktop-portal-termfilechooser = pkgs.callPackage ./xdg-desktop-portal-termfilechooser {};
# decker = pkgs.callPackage ./decker {}; # decker = pkgs.callPackage ./decker {};
} }

17
flake.lock generated
View File

@ -59,22 +59,6 @@
"type": "github" "type": "github"
} }
}, },
"firefox-gnome-theme": {
"flake": false,
"locked": {
"lastModified": 1727973442,
"narHash": "sha256-nf+0/UR5TZArp3Dn3NS3nB+ZGqecTOTOZRCFM3a1veM=",
"owner": "rafaelmardojai",
"repo": "firefox-gnome-theme",
"rev": "59eee4080aa79a0671e98358f91ae1ef0c0806e1",
"type": "github"
},
"original": {
"owner": "rafaelmardojai",
"repo": "firefox-gnome-theme",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"locked": { "locked": {
"lastModified": 1696426674, "lastModified": 1696426674,
@ -531,7 +515,6 @@
"inputs": { "inputs": {
"devshell": "devshell", "devshell": "devshell",
"emacs-overlay": "emacs-overlay", "emacs-overlay": "emacs-overlay",
"firefox-gnome-theme": "firefox-gnome-theme",
"hardware": "hardware", "hardware": "hardware",
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-alien": "nix-alien", "nix-alien": "nix-alien",

120
flake.nix
View File

@ -1,10 +1,9 @@
{ {
description = "ChUrl's very bad and basic Nix config using Flakes"; description = "ChUrl's NixOS config using Flakes";
# This config is a Flake. # This config is a Flake.
# It needs inputs that are passed as arguments to the output. # It depends on "inputs" that are passed as arguments to the "outputs" function.
# These are the dependencies of the Flake. # The inputs' git revisions get locked in the flake.lock file, making the outputs deterministic.
# The git revisions get locked in flake.lock to make the outputs deterministic.
inputs = { inputs = {
# Nixpkgs # Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
@ -14,51 +13,42 @@
home-manager.url = "github:nix-community/home-manager"; home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs";
# NeoVim # NeoVim <3
nixvim.url = "github:nix-community/nixvim"; nixvim.url = "github:nix-community/nixvim";
nixvim.inputs.nixpkgs.follows = "nixpkgs"; nixvim.inputs.nixpkgs.follows = "nixpkgs";
# Nix User Repository (e.g. Firefox addons)
nur.url = "github:nix-community/NUR";
# Other # Other
emacs-overlay.url = "github:nix-community/emacs-overlay";
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.4.1"; nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.4.1";
nix-alien.url = "github:thiagokokada/nix-alien"; nix-alien.url = "github:thiagokokada/nix-alien";
devshell.url = "github:numtide/devshell"; emacs-overlay.url = "github:nix-community/emacs-overlay";
nur.url = "github:nix-community/NUR"; # Nix User Repository
firefox-gnome-theme.url = "github:rafaelmardojai/firefox-gnome-theme";
firefox-gnome-theme.flake = false;
# Disabled # TODO: Move away from devshell, as it breaks e.g. C++/Rust library propagation
# adwaita-for-steam.url = "github:tkashkin/Adwaita-for-Steam"; # and doesn't provide any benefits for me
# adwaita-for-steam.flake = false; devshell.url = "github:numtide/devshell";
# plasma-manager.url = "github:pjones/plasma-manager";
# plasma-manager.inputs.nixpkgs.follows = "nixpkgs";
# plasma-manager.inputs.home-manager.follows = "home-manager";
# musnix.url = "github:musnix/musnix";
# nixified-ai.url = "github:nixified-ai/flake";
# nixos-conf-editor.url = "github:vlinkz/nixos-conf-editor";
# nix-matlab.url = "gitlab:doronbehar/nix-matlab";
}; };
# Outputs is a function that takes the inputs as arguments. # Outputs is a function that takes the inputs as arguments.
# To handle extra arguments we use the @ inputs pattern. # To handle extra arguments we use the @ inputs pattern.
# It gives the name "inputs" to the ... ellipses. # It gives the name "inputs" to the ... ellipses.
outputs = { outputs = {nixpkgs, ...} @ inputs: let
nixpkgs, # Our configuration is buildable on the following system/platform.
... # Configs can support more than a single system simultaneously,
} @ inputs: let # e.g. NixOS (linux) and MacOS (darwin) or Arm.
system = "x86_64-linux"; system = "x86_64-linux";
# TODO: Use those to generate configs # We configure our global packages here.
hostnames = ["nixinator" "nixtop"]; # Usually, "nixpkgs.legacyPackages.${system}" is used (and more efficient),
usernames = ["christoph"]; # but because we want to change the nixpkgs configuration, we have to re-import it.
# Set overlays + unfree globally
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
# config.allowUnfree = true; config.allowUnfree = true;
config.allowUnfreePredicate = pkg: true; config.allowUnfreePredicate = pkg: true;
# Overlays define changes in the nixpkgs package set.
overlays = [ overlays = [
inputs.devshell.overlays.default inputs.devshell.overlays.default
inputs.nur.overlay inputs.nur.overlay
@ -69,52 +59,80 @@
]; ];
}; };
# I don't know how to extend the nixpkgs.lib directly so just propagate mylib to the config modules as argument # My own library functions are imported here.
# They are made available to the system and HM configs by inheriting mylib.
mylib = import ./lib { mylib = import ./lib {
# Equal to "inputs = inputs;" and "pkgs = pkgs;".
# The right values come from the outer scope, because the names match
# in the inner and outer scope, we can use "inherit" instead.
# This is required because the lib/ module expects those as arguments.
inherit inputs pkgs; inherit inputs pkgs;
# Equal to "lib = nixpkgs.lib;". This is required, because mylib also uses the nixpkgs lib. # Equal to "lib = nixpkgs.lib;".
# This is required because mylib also uses the default nixpkgs lib.
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
}; };
in { in {
# Local shell for NixFlake directory # Local shell for NixFlake directory
devShells."${system}".default = import ./shell.nix {inherit pkgs;}; devShells."${system}".default = import ./shell.nix {inherit pkgs;};
# We give each configuration a name (the hostname) to choose a configuration when rebuilding. # We give each configuration a (host)name to choose a configuration when rebuilding.
# This makes it easy to add different configurations (e.g. for a laptop). # This makes it easy to add different configurations (e.g. for a laptop).
# Usage: sudo nixos-rebuild switch --flake .#nixinator # Usage: sudo nixos-rebuild switch --flake .#nixinator
# Usage: sudo nixos-rebuild switch --flake .#nixtop # Usage: sudo nixos-rebuild switch --flake .#nixtop
nixosConfigurations = { nixosConfigurations = {
# TODO: This should probably run using mapAttrs over the hostnames list... # These configurations include HM as a NixOS module. This has a few benefits:
nixinator = mylib.nixos.mkNixosSystemConfig { # - The system config is available from within the HM config,
# passed as nixosConfig input to each HM module
# - This seems to be required for opt-in persistence
# - The HM config can be rebuilt separately from the system,
# without generating a new boot entry
# Downsides:
# - The nixd HM options completion doesn't seem to work
# - The system needs to be rebuilt with every HM config change
nixinator = mylib.nixos.mkNixosConfigWithHomeManagerModule {
inherit system mylib; inherit system mylib;
hostname = "nixinator"; hostname = "nixinator";
username = "christoph";
extraModules = []; extraModules = [];
}; };
nixtop = mylib.nixos.mkNixosSystemConfig { nixtop = mylib.nixos.mkNixosConfigWithHomeManagerModule {
inherit system mylib; inherit system mylib;
hostname = "nixtop"; hostname = "nixtop";
username = "christoph";
extraModules = []; extraModules = [];
}; };
# These configurations don't include HM.
# When using those, HM has to be installed separately in homeConfigurations.
# nixinator = mylib.nixos.mkNixosSystemConfig {
# inherit system mylib;
# hostname = "nixinator";
# extraModules = [];
# };
# nixtop = mylib.nixos.mkNixosSystemConfig {
# inherit system mylib;
# hostname = "nixtop";
# extraModules = [];
# };
}; };
# The home configuration can be rebuilt separately: # The home configuration can be rebuilt separately:
# Usage: home-manager switch --flake .#christoph@nixinator # Usage: home-manager switch --flake .#christoph@nixinator
# Usage: home-manager switch --flake .#christoph@nixtop # Usage: home-manager switch --flake .#christoph@nixtop
homeConfigurations = { # homeConfigurations = {
# TODO: This should probably run using mapAttrs and cartesianProduct over the hostnames and usernames lists... # "christoph@nixinator" = mylib.nixos.mkNixosHomeConfig {
"christoph@nixinator" = mylib.nixos.mkNixosHomeConfig { # inherit system mylib;
inherit system mylib; # username = "christoph";
username = "christoph"; # hostname = "nixinator";
hostname = "nixinator"; # extraModules = [];
extraModules = []; # };
}; # "christoph@nixtop" = mylib.nixos.mkNixosHomeConfig {
"christoph@nixtop" = mylib.nixos.mkNixosHomeConfig { # inherit system mylib;
inherit system mylib; # username = "christoph";
username = "christoph"; # hostname = "nixtop";
hostname = "nixtop"; # extraModules = [];
extraModules = []; # };
}; # };
};
}; };
} }

View File

@ -32,30 +32,6 @@ rec {
google = false; google = false;
}; };
# emacs = {
# enable = false;
# pgtkNativeComp = false;
# nativeComp = false;
# nixpkgs = true;
# doom.enable = true;
# doom.autoSync = true;
# doom.autoUpgrade = false; # Very volatile as the upgrade fails sometimes with bleeding edge emacs
# };
# TODO: Only sync protonmail using its bridge
email = {
enable = false;
autosync = true;
imapnotify = false;
# Use kmail as viewer for stuff synced by mbsync
kmail = {
enable = false;
autostart = true;
};
};
firefox = { firefox = {
enable = true; enable = true;
wayland = true; wayland = true;
@ -67,8 +43,6 @@ rec {
fish.enable = true; fish.enable = true;
helix.enable = false;
hyprland = { hyprland = {
enable = true; enable = true;
# theme = "Three-Bears"; # theme = "Three-Bears";
@ -174,19 +148,12 @@ rec {
nnn.enable = true; nnn.enable = true;
# ranger = {
# enable = false;
# preview = true;
# };
rofi = { rofi = {
enable = true; enable = true;
# theme = "Three-Bears"; # theme = "Three-Bears";
theme = "Foggy-Lake"; theme = "Foggy-Lake";
}; };
vscode.enable = false; # TODO: Had broken package ms-vscode-cpptools
waybar = { waybar = {
enable = true; enable = true;
}; };

View File

@ -1,25 +1,29 @@
{inputs, ...}: { {inputs, ...}: {
imports = [ imports = [
# Obsolete modules are kept in this folder for reference.
# ./audio # ./audio
# ./emacs
# ./email
# ./flatpak
# ./helix
# ./gaming
# ./misc
# ./nextcloud
# ./ranger
# ./vscode
# My own HM modules
./chromium ./chromium
./emacs
./email
./firefox ./firefox
./fish ./fish
# ./flatpak
# ./gaming
./helix
./hyprland ./hyprland
./kitty ./kitty
# ./misc
./neovim ./neovim
# ./nextcloud
./nnn ./nnn
./ranger
./rofi ./rofi
./vscode
./waybar ./waybar
# HM modules imported from the flake inputs
inputs.nix-flatpak.homeManagerModules.nix-flatpak inputs.nix-flatpak.homeManagerModules.nix-flatpak
inputs.nixvim.homeManagerModules.nixvim inputs.nixvim.homeManagerModules.nixvim
]; ];

View File

@ -7,19 +7,20 @@
mylib, mylib,
pkgs, pkgs,
... ...
}: let } @ inputs: let
cfg = config.modules.hyprland; cfg = config.modules.hyprland;
in { in {
options.modules.hyprland = import ./options.nix {inherit lib mylib;}; options.modules.hyprland = import ./options.nix {inherit lib mylib;};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# TODO: Can't get the nixosConfig from standalone HM... assertions = [
# assertions = [ {
# { # This assertion is not possible if HM is used standalone,
# assertion = (import <nixpkgs/nixos> {}).config.programs.hyprland.enable; # because nixosConfig won't be available.
# message = "Can't enable Hyprland module with Hyprland disabled!"; assertion = inputs.nixosConfig.programs.hyprland.enable;
# } message = "Can't enable Hyprland module with Hyprland disabled!";
# ]; }
];
gtk = { gtk = {
enable = true; enable = true;

View File

@ -15,6 +15,9 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
home = { home = {
file.".config/neovide/config.toml".source = ./neovide_config.ini;
file.".config/vale/.vale.ini".source = ./vale_config.ini;
sessionVariables = { sessionVariables = {
EDITOR = "nvim"; EDITOR = "nvim";
VISUAL = "nvim"; VISUAL = "nvim";
@ -67,9 +70,6 @@ in {
stylua stylua
] ]
]; ];
file.".config/neovide/config.toml".source = ./neovide_config.ini;
file.".config/vale/.vale.ini".source = ./vale_config.ini;
}; };
programs.nixvim = { programs.nixvim = {
@ -108,6 +108,7 @@ in {
extraConfigLuaPost = builtins.readFile ./extraConfigLuaPost.lua; extraConfigLuaPost = builtins.readFile ./extraConfigLuaPost.lua;
extraConfigLua = builtins.readFile ./extraConfigLua.lua; extraConfigLua = builtins.readFile ./extraConfigLua.lua;
# Those files will be added to the nvim runtimpath
extraFiles = { extraFiles = {
# For this its probably important to set the default filetype to tex (see extraConfigLua) # For this its probably important to set the default filetype to tex (see extraConfigLua)
"ftplugin/tex/mappings.lua".text = mylib.generators.toLuaKeymap (import ./mappings_latex.nix {}); "ftplugin/tex/mappings.lua".text = mylib.generators.toLuaKeymap (import ./mappings_latex.nix {});
@ -907,7 +908,6 @@ in {
{name = "clojure_lsp";} {name = "clojure_lsp";}
{name = "cmake";} {name = "cmake";}
{name = "lua_ls";} {name = "lua_ls";}
# {name = "nil_ls";} # TODO: To use together with nixd, its hover functionality needs to be disabled to not conflict
{ {
name = "ltex"; name = "ltex";
extraOptions.settings = { extraOptions.settings = {
@ -916,9 +916,9 @@ in {
}; };
}; };
} }
# {name = "nil_ls";} # Conflicts with nixd's hover
{ {
name = "nixd"; name = "nixd";
# TODO: Figure out how to structure this attrset
extraOptions.settings = { extraOptions.settings = {
nixd = { nixd = {
nixpkgs = { nixpkgs = {
@ -931,9 +931,10 @@ in {
nixos = { nixos = {
expr = "(builtins.getFlake \"/home/${username}/NixFlake\").nixosConfigurations.${hostname}.options"; expr = "(builtins.getFlake \"/home/${username}/NixFlake\").nixosConfigurations.${hostname}.options";
}; };
home_manager = { # When using HM as a NixOS module, nixd's HM option completion doesn't work.
expr = "(builtins.getFlake \"/home/${username}/NixFlake\").homeConfigurations.\"${username}@${hostname}\".options"; # home_manager = {
}; # expr = "(builtins.getFlake \"/home/${username}/NixFlake\").homeConfigurations.\"${username}@${hostname}\".options";
# };
}; };
diagnostic = { diagnostic = {
suppress = [ suppress = [

View File

@ -16,7 +16,7 @@
# Make our inputs available to the configuration.nix (for importing modules) # Make our inputs available to the configuration.nix (for importing modules)
# specialArgs are propagated to all modules # specialArgs are propagated to all modules
specialArgs = {inherit inputs hostname username mylib system;}; specialArgs = {inherit inputs hostname mylib system username;};
modules = builtins.concatLists [ modules = builtins.concatLists [
[ [
@ -29,10 +29,7 @@
extraModules extraModules
# I included the home config statically like this as I am the only user. # HM is installed as a system module
# I would have liked to make it more flexible (for multiple users on the same host)
# but I failed because nix stopped autoinjecting the required arguments and I didn't
# know how to handle that...
[ [
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
{ {
@ -88,7 +85,7 @@
inputs.home-manager.lib.homeManagerConfiguration { inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
# Make this stuff available to the hm modules # HM propagates these to every module
extraSpecialArgs = {inherit inputs system mylib username hostname;}; extraSpecialArgs = {inherit inputs system mylib username hostname;};
modules = builtins.concatLists [ modules = builtins.concatLists [