1

Nixos: Switch to standalone Home-Manager

Not everything is working yet, derivations have to be rewritten
This commit is contained in:
2024-10-11 04:29:03 +02:00
parent f2f6821240
commit aab27a4025
7 changed files with 136 additions and 113 deletions

View File

@ -1,17 +1,18 @@
{ {
inputs, inputs,
pkgs, pkgs,
mylib,
... ...
}: { }: {
# vital-synth = pkgs.callPackage ./vital-synth {}; # Kept as an example, don't know if I will fix this or keep using distrho # vital-synth = pkgs.callPackage ./vital-synth {}; # Kept as an example, don't know if I will fix this or keep using distrho
# adwaita-for-steam = pkgs.callPackage ./adwaita-for-steam {src = inputs.adwaita-for-steam;}; # adwaita-for-steam = pkgs.callPackage ./adwaita-for-steam {src = inputs.adwaita-for-steam;};
# dconf-editor-wrapped = pkgs.callPackage ./dconf-editor-wrapped {}; # dconf-editor-wrapped = pkgs.callPackage ./dconf-editor-wrapped {};
dell-b1160w = pkgs.callPackage ./dell-b1160w {};
firefox-gnome-theme = pkgs.callPackage ./firefox-gnome-theme {src = inputs.firefox-gnome-theme;};
# modules-options-doc = pkgs.callPackage ./modules-options-doc {mylib = mylib;}; # TODO: Borked # modules-options-doc = pkgs.callPackage ./modules-options-doc {mylib = mylib;}; # TODO: Borked
# spotdl-4_1_6 = pkgs.callPackage ./spotdl-4_1_6 {}; # TODO: Old # spotdl-4_1_6 = pkgs.callPackage ./spotdl-4_1_6 {}; # TODO: Old
xdg-desktop-portal-termfilechooser = pkgs.callPackage ./xdg-desktop-portal-termfilechooser {};
# wiiu-downloader = pkgs.callPackage ./wiiu-downloader {}; # wiiu-downloader = pkgs.callPackage ./wiiu-downloader {};
decker = pkgs.callPackage ./decker {};
# TODO: Those were enabled, but have to be rewritten for standalone HM
# 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 {};
# decker = pkgs.callPackage ./decker {};
} }

View File

@ -1,4 +1,3 @@
# The curly braces denote a set of keys and values.
{ {
description = "ChUrl's very bad and basic Nix config using Flakes"; description = "ChUrl's very bad and basic Nix config using Flakes";
@ -15,9 +14,11 @@
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";
# Other # NeoVim
nixvim.url = "github:nix-community/nixvim"; nixvim.url = "github:nix-community/nixvim";
nixvim.inputs.nixpkgs.follows = "nixpkgs"; nixvim.inputs.nixpkgs.follows = "nixpkgs";
# Other
emacs-overlay.url = "github:nix-community/emacs-overlay"; 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";
@ -39,79 +40,80 @@
}; };
# 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 a name to the ... ellipses. # It gives the name "inputs" to the ... ellipses.
outputs = inputs @ { outputs = {
nixpkgs, nixpkgs,
# home-manager,
# hyprland,
... ...
}: } @ inputs: let
# With let you can define local variables
let
system = "x86_64-linux"; system = "x86_64-linux";
# I don't know how to extend the nixpkgs.lib directly so just propagate mylib to the config modules as argument # TODO: Use those to generate configs
mylib = import ./lib { hostnames = ["nixinator" "nixtop"];
inherit inputs pkgs; usernames = ["christoph"];
inherit (nixpkgs) lib; # Equal to "lib = nixpkgs.lib;"
};
# Set overlays + unfree globally # Set overlays + unfree globally
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
config.allowUnfree = true; # config.allowUnfree = true;
config.allowUnfreePredicate = pkg: true;
# NOTE: Obsidian 1.5.3 depends on an unsupported Electron version. As long as Obsidian isn't updated, allow this version.
config.permittedInsecurePackages = pkgs.lib.optional (pkgs.obsidian.version == "1.5.3") "electron-25.9.0";
# NOTE: Probably shouldn't enable CUDA globally, but in the environment flakes where it is needed?
# Would it even work here? Since the flake imports its own nixpkgs...
# config.cudaSupport = true;
overlays = [ overlays = [
inputs.devshell.overlays.default inputs.devshell.overlays.default
inputs.nur.overlay inputs.nur.overlay
inputs.emacs-overlay.overlay inputs.emacs-overlay.overlay
# inputs.hyprpaper.overlays.default
# inputs.hyprpicker.overlays.default
# All my own overlays # All my own overlays
(import ./overlays {inherit nixpkgs inputs mylib;}) (import ./overlays {inherit nixpkgs inputs;})
]; ];
}; };
# The rec expression turns a basic set into a set where self-referencing is possible.
# It is a shorthand for recursive and allows to use the values defined in this set from its own scope. # I don't know how to extend the nixpkgs.lib directly so just propagate mylib to the config modules as argument
mylib = import ./lib {
inherit inputs pkgs;
# Equal to "lib = nixpkgs.lib;". This is required, because mylib also uses the 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;};
# System configurations + HomeManager module # We give each configuration a name (the hostname) to choose a configuration when rebuilding.
# Accessible via 'nixos-rebuild' # 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 .#nixtop
nixosConfigurations = { nixosConfigurations = {
# We give our configuration a name (the hostname) to choose a configuration when rebuilding. # TODO: This should probably run using mapAttrs over the hostnames list...
# This makes it easy to add different configurations (e.g. for a laptop). nixinator = mylib.nixos.mkNixosSystemConfig {
# Usage: sudo nixos-rebuild switch --flake .#nixinator
nixinator = mylib.nixos.mkNixosConfig {
inherit system mylib; inherit system mylib;
hostname = "nixinator"; hostname = "nixinator";
username = "christoph"; extraModules = [];
extraModules = [
];
}; };
nixtop = mylib.nixos.mkNixosSystemConfig {
# Usage: sudo nixos-rebuild switch --flake .#nixtop
nixtop = mylib.nixos.mkNixosConfig {
inherit system mylib; inherit system mylib;
hostname = "nixtop"; hostname = "nixtop";
username = "christoph"; extraModules = [];
};
};
extraModules = [ # The home configuration can be rebuilt separately:
]; # Usage: home-manager switch --flake .#christoph@nixinator
# Usage: home-manager switch --flake .#christoph@nixtop
homeConfigurations = {
# TODO: This should probably run using mapAttrs and cartesianProduct over the hostnames and usernames lists...
"christoph@nixinator" = mylib.nixos.mkNixosHomeConfig {
inherit system mylib;
username = "christoph";
hostname = "nixinator";
extraModules = [];
};
"christoph@nixtop" = mylib.nixos.mkNixosHomeConfig {
inherit system mylib;
username = "christoph";
hostname = "nixtop";
extraModules = [];
}; };
}; };
}; };

View File

@ -8,14 +8,12 @@
lib, lib,
mylib, mylib,
config, config,
nixosConfig,
pkgs, pkgs,
... ...
}: }:
# This is a module # This is a module
# Because no imports/options/config is defined explicitly, everything is treated as config # Because no imports/options/config is defined explicitly, everything is treated as config
# { inputs, lib, ... }: { ... } gets turned into { inputs, lib, ... }: { config = { ... }; } implicitly # { inputs, lib, ... }: { ... } gets turned into { inputs, lib, ... }: { config = { ... }; } implicitly
# TODO: Add nixified.ai module
rec { rec {
# Every module is a nix expression, specifically a function { inputs, lib, ... }: { ... } # Every module is a nix expression, specifically a function { inputs, lib, ... }: { ... }
# Every module (/function) is called with the same arguments as this module (home.nix) # Every module (/function) is called with the same arguments as this module (home.nix)
@ -26,9 +24,6 @@ rec {
./${hostname} ./${hostname}
../modules ../modules
# inputs.nixvim.homeManagerModules.nixvim
# inputs.hyprland.homeManagerModules.default
]; ];
modules = { modules = {
@ -72,21 +67,6 @@ rec {
fish.enable = true; fish.enable = true;
# flatpak = {
# enable = false;
# autoUpdate = true;
# autoPrune = true;
# fontFix = true; # TODO: This doesn't work reliably...
# iconFix = false;
# flatseal.enable = true;
# discord.enable = true;
# spotify.enable = true;
# bottles.enable = false;
# obsidian.enable = false; # Extremely low graph draw performance?
# jabref.enable = false;
# };
helix.enable = false; helix.enable = false;
hyprland = { hyprland = {
@ -221,15 +201,16 @@ rec {
# NOTE: I don't think I need this anymore as all fonts are installed through the system config but let's keep this just in case # NOTE: I don't think I need this anymore as all fonts are installed through the system config but let's keep this just in case
fonts.fontconfig.enable = true; # Also updates the font-cache fonts.fontconfig.enable = true; # Also updates the font-cache
xdg = { # TODO: Borked after standalone HM
mime.enable = true; # xdg = {
mimeApps = { # mime.enable = true;
enable = true; # mimeApps = {
associations.added = nixosConfig.xdg.mime.addedAssociations; # enable = true;
associations.removed = nixosConfig.xdg.mime.removedAssociations; # associations.added = nixosConfig.xdg.mime.addedAssociations;
inherit (nixosConfig.xdg.mime) defaultApplications; # Equal to "defaultApplications = nixosConfig.xdg.mime.defaultApplications" # associations.removed = nixosConfig.xdg.mime.removedAssociations;
}; # inherit (nixosConfig.xdg.mime) defaultApplications; # Equal to "defaultApplications = nixosConfig.xdg.mime.defaultApplications"
}; # };
# };
home = { home = {
inherit username; # Inherited from flake.nix inherit username; # Inherited from flake.nix
@ -338,7 +319,6 @@ rec {
ffmpeg_7-full # I love ffmpeg (including ffplay) ffmpeg_7-full # I love ffmpeg (including ffplay)
ffmpeg-normalize ffmpeg-normalize
imagemagick # Convert image (magic) imagemagick # Convert image (magic)
# ueberzugpp # Display images in terminal (alacritty) # TODO: Build failure
# Document utils # Document utils
# TODO: Latex module with individual packages or HomeManager # TODO: Latex module with individual packages or HomeManager
@ -363,12 +343,10 @@ rec {
rsync # cp on steroids rsync # cp on steroids
rclone # Rsync for cloud rclone # Rsync for cloud
httpie # Cool http client httpie # Cool http client
# suricata
cifs-utils # Mount samba shares cifs-utils # Mount samba shares
nfs-utils nfs-utils
sshfs sshfs
protonvpn-cli protonvpn-cli
# protonvpn-gui # NOTE: Doesn't work
# GUI apps # GUI apps
vlc vlc
@ -377,28 +355,23 @@ rec {
sqlitebrowser # To modify tables sqlitebrowser # To modify tables
dbeaver-bin # To import/export data + diagrams dbeaver-bin # To import/export data + diagrams
hoppscotch # Test APIs hoppscotch # Test APIs
# decker # TODO: Build failure
signal-desktop signal-desktop
filezilla filezilla
anki anki
# octave # GNU matlab basically
font-manager font-manager
nextcloud-client nextcloud-client
keepassxc keepassxc
protonmail-bridge protonmail-bridge
thunderbird # TODO: Email module thunderbird # TODO: Email module
# xwaylandvideobridge # NOTE: Doesn't work
AusweisApp2 AusweisApp2
# decker # TODO: Build failure
# Office # Office
wacomtablet # For xournalpp/krita wacomtablet # For xournalpp/krita
xournalpp # Write with a pen, like old people xournalpp # Write with a pen, like old people
# libreoffice-qt
hunspell # I cna't type hunspell # I cna't type
hunspellDicts.en_US hunspellDicts.en_US
hunspellDicts.de_DE hunspellDicts.de_DE
# obsidian # knowledge-base # NOTE: Use flatpak
# logseq # knowledge-base
# TODO: Module, I need to add python packages from multiple modules to the same interpreter # TODO: Module, I need to add python packages from multiple modules to the same interpreter
python312 python312
@ -589,7 +562,7 @@ rec {
enableFishIntegration = config.modules.fish.enable; enableFishIntegration = config.modules.fish.enable;
}; };
gallery-dl.enable = false; # TODO: Alternative to cyberdrop-dl? gallery-dl.enable = false;
git = { git = {
enable = true; enable = true;

View File

@ -1,11 +1,10 @@
# TODO: https://github.com/nix-community/home-manager/commit/69d19b9839638fc487b370e0600a03577a559081 # TODO: https://github.com/nix-community/home-manager/commit/69d19b9839638fc487b370e0600a03577a559081
{ {
inputs,
config, config,
nixosConfig,
lib, lib,
mylib, mylib,
pkgs, pkgs,
hostname,
... ...
}: }:
with lib; with lib;
@ -24,7 +23,8 @@ in {
# libvdpau # libvdpau
]) ])
(optionals cfg.gnomeTheme [firefox-gnome-theme]) # TODO: Derivation borked on standalone HM
# (optionals cfg.gnomeTheme [firefox-gnome-theme])
]; ];
home.sessionVariables = mkMerge [ home.sessionVariables = mkMerge [
@ -99,9 +99,10 @@ in {
id = 0; # 0 is default profile id = 0; # 0 is default profile
userChrome = concatStringsSep "\n" [ userChrome = concatStringsSep "\n" [
(optionalString cfg.gnomeTheme '' # TODO: Borked after standalone HM
@import "${pkgs.firefox-gnome-theme}/share/firefox-gnome-theme/gnome-theme.css"; # (optionalString cfg.gnomeTheme ''
'') # @import "${pkgs.firefox-gnome-theme}/share/firefox-gnome-theme/gnome-theme.css";
# '')
(optionalString cfg.disableTabBar '' (optionalString cfg.disableTabBar ''
#TabsToolbar { display: none; } #TabsToolbar { display: none; }
@ -252,7 +253,8 @@ in {
"geo.provider.network.url" = "https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%"; "geo.provider.network.url" = "https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%";
"geo.provider.use_gpsd" = false; "geo.provider.use_gpsd" = false;
"identity.fxaccounts.account.device.name" = nixosConfig.networking.hostName; "identity.fxaccounts.account.device.name" = hostname;
"media.hardwaremediakeys.enabled" = false; # Do not interfere with spotify "media.hardwaremediakeys.enabled" = false; # Do not interfere with spotify
"media.videocontrols.picture-in-picture.video-toggle.enabled" = true; "media.videocontrols.picture-in-picture.video-toggle.enabled" = true;

View File

@ -3,7 +3,6 @@
# TODO: The border color does not fit the current theme # TODO: The border color does not fit the current theme
{ {
config, config,
nixosConfig,
lib, lib,
mylib, mylib,
pkgs, pkgs,
@ -14,12 +13,13 @@ 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 {
assertions = [ # TODO: Can't get the nixosConfig from standalone HM...
{ # assertions = [
assertion = nixosConfig.programs.hyprland.enable; # {
message = "Can't enable Hyprland module with Hyprland disabled!"; # assertion = (import <nixpkgs/nixos> {}).config.programs.hyprland.enable;
} # message = "Can't enable Hyprland module with Hyprland disabled!";
]; # }
# ];
gtk = { gtk = {
enable = true; enable = true;

View File

@ -3,14 +3,12 @@
pkgs, pkgs,
lib, lib,
... ...
}: let }: {
inherit (inputs) home-manager; mkNixosConfigWithHomeManagerModule = {
in { system,
mkNixosConfig = {
system ? "x86_64-linux",
mylib, mylib,
hostname, hostname,
username ? "christoph", username,
extraModules ? [], extraModules ? [],
}: }:
lib.nixosSystem { lib.nixosSystem {
@ -36,7 +34,7 @@ in {
# but I failed because nix stopped autoinjecting the required arguments and I didn't # but I failed because nix stopped autoinjecting the required arguments and I didn't
# know how to handle that... # know how to handle that...
[ [
home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
{ {
# extraSpecialArgs are propagated to all hm config modules # extraSpecialArgs are propagated to all hm config modules
home-manager.extraSpecialArgs = {inherit inputs hostname username mylib;}; home-manager.extraSpecialArgs = {inherit inputs hostname username mylib;};
@ -53,4 +51,52 @@ in {
] ]
]; ];
}; };
mkNixosSystemConfig = {
system,
mylib,
hostname,
extraModules ? [],
}:
lib.nixosSystem {
inherit system;
# Make our inputs available to the configuration.nix (for importing modules)
# specialArgs are propagated to all modules
specialArgs = {inherit inputs hostname mylib system;};
modules = builtins.concatLists [
[
# Replace the pkgs to include overlays/unfree
{nixpkgs.pkgs = pkgs;}
# Main config file for all configs/hosts
../system
]
extraModules
];
};
mkNixosHomeConfig = {
system,
mylib,
username,
hostname,
extraModules ? [],
}:
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Make this stuff available to the hm modules
extraSpecialArgs = {inherit inputs system mylib username hostname;};
modules = builtins.concatLists [
[
../home/${username}
]
extraModules
];
};
} }

View File

@ -1,14 +1,13 @@
{ {
inputs, inputs,
nixpkgs, nixpkgs,
mylib,
... ...
}: let }: let
# Taken from https://github.com/Misterio77/nix-config/blob/main/overlay/default.nix # Taken from https://github.com/Misterio77/nix-config/blob/main/overlay/default.nix
# By specifying this we can just add our derivation to derivations/default.nix and it will land here # By specifying this we can just add our derivation to derivations/default.nix and it will land here
additions = final: prev: additions = final: prev:
import ../derivations { import ../derivations {
inherit inputs mylib; inherit inputs;
pkgs = final; pkgs = final;
}; };