feat: atomically track unfree software and enable it

This commit is contained in:
Youwen Wu 2024-12-24 18:19:06 -08:00
parent 180741ec71
commit 190faacb64
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
7 changed files with 62 additions and 46 deletions

View file

@ -15,6 +15,8 @@
]; ];
liminalOS = { liminalOS = {
flakeLocation = "/home/youwen/.config/liminalOS";
config.allowUnfree = true;
system = { system = {
audio.prod.enable = true; audio.prod.enable = true;
networking = { networking = {
@ -22,6 +24,10 @@
firewallPresets.vite = true; firewallPresets.vite = true;
cloudflareNameservers.enable = true; cloudflareNameservers.enable = true;
}; };
graphics = {
enable = true;
nvidia.enable = true;
};
}; };
theming.enable = true; theming.enable = true;
desktop.enable = true; desktop.enable = true;
@ -113,8 +119,6 @@
NetworkManager-wait-online.enable = false; NetworkManager-wait-online.enable = false;
}; };
hardware.enableAllFirmware = true;
# Enable the X11 windowing system. # Enable the X11 windowing system.
# You can disable this if you're only using the Wayland session. # You can disable this if you're only using the Wayland session.
services.xserver.enable = false; services.xserver.enable = false;
@ -128,14 +132,6 @@
]; ];
}; };
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = true;
powerManagement.finegrained = false;
open = false;
nvidiaSettings = true;
};
hardware.bluetooth = { hardware.bluetooth = {
enable = true; enable = true;
powerOnBoot = true; powerOnBoot = true;
@ -143,12 +139,6 @@
services.blueman.enable = true; services.blueman.enable = true;
hardware.graphics.enable = true;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta;
services.xserver.videoDrivers = [ "nvidia" ];
# services.desktopManager.plasma6.enable = true; # services.desktopManager.plasma6.enable = true;
# Configure keymap in X11 # Configure keymap in X11
@ -178,9 +168,6 @@
KERNEL=="cpu_dma_latency", GROUP="realtime" KERNEL=="cpu_dma_latency", GROUP="realtime"
''; '';
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View file

@ -21,5 +21,9 @@ in
yabridge yabridge
yabridgectl yabridgectl
]; ];
liminalOS.config.extraUnfreePackages = lib.mkIf config.liminalOS.config.allowUnfree [
"reaper"
];
}; };
} }

View file

@ -45,13 +45,6 @@ in
Whether to enable the `nh` cli (yet another Nix helper), a reimplementation of some core NixOS utilities like nix-collect-garbage and nixos-rebuild. If enabled, automatic garbage collection will use `nh` instead of `nix-collect-garbage` and will be able to garbage collect `result` symlinks. Whether to enable the `nh` cli (yet another Nix helper), a reimplementation of some core NixOS utilities like nix-collect-garbage and nixos-rebuild. If enabled, automatic garbage collection will use `nh` instead of `nix-collect-garbage` and will be able to garbage collect `result` symlinks.
''; '';
}; };
flakeLocation = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Absolute filepath location of the NixOS system configuration flake.
'';
};
suppressWarnings = lib.mkEnableOption "suppress warnings"; suppressWarnings = lib.mkEnableOption "suppress warnings";
}; };
@ -124,15 +117,17 @@ in
enable = true; enable = true;
extraArgs = "--keep-since 4d --keep 3"; extraArgs = "--keep-since 4d --keep 3";
}; };
flake = cfg.flakeLocation; flake = config.liminalOS.flakeLocation;
}; };
boot.tmp.cleanOnBoot = true; boot.tmp.cleanOnBoot = true;
hardware.enableRedistributableFirmware = true;
warnings = warnings =
if !cfg.suppressWarnings && cfg.useNh && cfg.flakeLocation == "" then if !cfg.suppressWarnings && cfg.useNh && config.liminalOS.flakeLocation == "" then
[ [
''The `nh` CLI is enabled but `liminalOS.system.core.flakeLocation` is not set. It is recommended that you set this option so that `nh` can work without specifying the flake path every time. You can disable this warning by setting `liminalOS.system.core.suppressWarnings`.'' ''The `nh` CLI is enabled but `liminalOS.flakeLocation` is not set. It is recommended that you set this option to the absolute file path of your configuration flake so that `nh` can work without specifying the flake path every time. You can disable this warning by setting `liminalOS.system.core.suppressWarnings`.''
] ]
else else
[ ]; [ ];

View file

@ -14,6 +14,7 @@
./stylix ./stylix
./wine ./wine
./wsl ./wsl
./graphics
]; ];
options.liminalOS.enable = lib.mkOption { options.liminalOS.enable = lib.mkOption {

View file

@ -42,6 +42,8 @@ in
heroic heroic
mangohud mangohud
mangojuice mangojuice
r2modman
modrinth-app
]; ];
liminalOS.programs.flatpak.enable = true; liminalOS.programs.flatpak.enable = true;
@ -81,6 +83,13 @@ in
}; };
}; };
liminalOS.config.extraUnfreePackages = lib.mkIf config.liminalOS.config.allowUnfree [
"modrinth-app"
"modrinth-app-unwrapped"
"steam"
"steam-unwrapped"
];
users.users = forAllGamemodeUsers (username: { users.users = forAllGamemodeUsers (username: {
extraGroups = [ "gamemode" ]; extraGroups = [ "gamemode" ];
}); });

View file

@ -5,38 +5,58 @@
... ...
}: }:
let let
cfg = config.liminalOS.system; cfg = config.liminalOS;
inherit (lib) mkIf; inherit (lib) mkIf;
in in
{ {
options.liminalOS.system = { options.liminalOS = {
printing.enable = lib.mkOption { system.printing.enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = config.liminalOS.enable; default = config.liminalOS.enable;
description = '' description = ''
Whether to set up default options for printing and printer discover on UNIX. Whether to set up default options for printing and printer discover on UNIX.
''; '';
}; };
fonts.enable = lib.mkOption { system.fonts.enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = config.liminalOS.enable; default = config.liminalOS.enable;
description = '' description = ''
Whether to set up some nice default fonts, including a Nerd Font, Noto Fonts, and CJK. Whether to set up some nice default fonts, including a Nerd Font, Noto Fonts, and CJK.
''; '';
}; };
distrobox.enable = lib.mkEnableOption "distrobox and podman"; config.allowUnfree = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable some proprietary packages required by certain liminalOS modules. This does not set allowUnfree for the whole system, it merely allows the installation of a few proprietary packages such as Nvidia drivers, etc. You should still set this option even if you already set nixpkgs.config.allowUnfree for the whole system since it tells liminalOS it can enable certain options that require proprietary packages.
'';
};
config.extraUnfreePackages = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = ''
Packages to enable in allowUnfreePredicate
'';
};
flakeLocation = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Absolute filepath location of the NixOS system configuration flake.
'';
};
}; };
config = { config = {
services.printing.enable = mkIf cfg.printing.enable true; services.printing.enable = mkIf cfg.system.printing.enable true;
services.avahi = mkIf cfg.printing.enable { services.avahi = mkIf cfg.system.printing.enable {
enable = true; enable = true;
nssmdns4 = true; nssmdns4 = true;
openFirewall = true; openFirewall = true;
}; };
fonts = mkIf cfg.fonts.enable { fonts = mkIf cfg.system.fonts.enable {
enableDefaultPackages = true; enableDefaultPackages = true;
packages = packages =
with pkgs; with pkgs;
@ -51,11 +71,14 @@ in
]); ]);
}; };
virtualisation.podman = mkIf cfg.distrobox.enable { nixpkgs.config.allowUnfreePredicate = lib.mkIf config.liminalOS.config.allowUnfree (
enable = true; pkg:
dockerCompat = true; builtins.elem (pkgs.lib.getName pkg) (
}; config.liminalOS.config.extraUnfreePackages
++ [
environment.systemPackages = mkIf cfg.distrobox.enable [ pkgs.distrobox ]; "spotify"
]
)
);
}; };
} }

View file

@ -11,10 +11,7 @@ in
(createCommon pkgs) (createCommon pkgs)
++ (with pkgs; [ ++ (with pkgs; [
bitwarden-desktop bitwarden-desktop
modrinth-app
sbctl sbctl
r2modman
zoom-us
]); ]);
home.sessionVariables = { home.sessionVariables = {