From ffb6be2ea2a9736409cb5d5244a457819b076d4b Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Mon, 19 Feb 2024 06:42:58 +0100 Subject: [PATCH] Don't depend on external nixos-unstable channel modules can now use unstablePkgs argument --- nix-os/account.nix | 10 +++++----- nix-os/desktop/gnome.nix | 10 +++++----- nix-os/shell.nix | 8 +++++--- nix-os/unstable-packages.nix | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 nix-os/unstable-packages.nix diff --git a/nix-os/account.nix b/nix-os/account.nix index a87929a..d6f763e 100644 --- a/nix-os/account.nix +++ b/nix-os/account.nix @@ -1,9 +1,9 @@ -{ config, pkgs, ... }: +{ config, pkgs, unstablePkgs, ... }: -let - unstable = import { config = config.nixpkgs.config; }; -in { + imports = [ + ./unstable-packages.nix + ]; users.users.wroclaw = { isNormalUser = true; description = "RafaƂ"; @@ -20,7 +20,7 @@ in firefox vivaldi discord-canary - unstable.vscode + unstablePkgs.vscode ]; }; users.groups.wroclaw.gid = 1000; diff --git a/nix-os/desktop/gnome.nix b/nix-os/desktop/gnome.nix index a2241fc..f1e8114 100644 --- a/nix-os/desktop/gnome.nix +++ b/nix-os/desktop/gnome.nix @@ -1,9 +1,9 @@ -{lib, config, pkgs, ...}: +{lib, config, pkgs, unstablePkgs, ...}: -let - unstable = import {}; -in { + imports = [ + ../unstable-packages.nix + ]; config = rec { services.xserver.enable = true; services.xserver.desktopManager.gnome.enable = true; @@ -207,7 +207,7 @@ in gnomeExtensions.tray-icons-reloaded gnomeExtensions.color-picker gnomeExtensions.top-bar-organizer - # unstable.gnomeExtensions.translate-indicator + # unstablePkgs.gnomeExtensions.translate-indicator # translate-shell pavucontrol #FIXME: Apply the cursor theme also in GTK3 config diff --git a/nix-os/shell.nix b/nix-os/shell.nix index 0e263d8..c716306 100644 --- a/nix-os/shell.nix +++ b/nix-os/shell.nix @@ -1,7 +1,6 @@ -{ config, pkgs, ... }: +{ config, pkgs, unstablePkgs, ... }: let - unstable = import {}; rangerGit = pkgs.ranger.overrideAttrs (old: { version = "git"; src = pkgs.fetchFromGitHub { @@ -20,6 +19,9 @@ let }); in { + imports = [ + ./unstable-packages.nix + ]; environment.systemPackages = with pkgs; [ rangerGit kitty @@ -50,7 +52,7 @@ in set vcs_aware true set show_hidden true - alias drag shell ${unstable.ripdrag}/bin/ripdrag -Axd %p & + alias drag shell ${unstablePkgs.ripdrag}/bin/ripdrag -Axd %p & map drag ''; diff --git a/nix-os/unstable-packages.nix b/nix-os/unstable-packages.nix new file mode 100644 index 0000000..67f0f5b --- /dev/null +++ b/nix-os/unstable-packages.nix @@ -0,0 +1,36 @@ +{config, pkgs, lib, ...}: + +let + nixos-unstable-exprs = builtins.fetchTarball https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz; + nixos-unstable = import nixos-unstable-exprs { + inherit (config.nixpkgs) config localSystem crossSystem; + overlays = if config.unstable.usePkgsOverlays then config.pkgs.overlays else []; + }; + nixos-unstable-version = builtins.concatStringsSep "." [ + (builtins.readFile "${builtins.toString nixos-unstable-exprs}/.version") + (builtins.readFile "${builtins.toString nixos-unstable-exprs}/.version-suffix") + ]; +in +{ + options.unstable = { + enable = lib.mkEnableOption (lib.mkDoc '' + use of unstable packages in configuration. You can use `unstablePkgs` in configuration modules + '') // { default = true; }; + usePkgsOverlays = lib.mkEnableOption (lib.mkDoc '' + use overlays from `nixpkgs.overlays` + ''); + pkgs = lib.mkOption { + default = if config.unstable.enable then nixos-unstable else pkgs; + description = lib.mkDoc '' + acts like pkgs, but it has unstable packages if `unstable.enable` is enabled. + You can also use `unstablePkgs` in module arguments. + ''; + visible = true; + readOnly = true; + type = lib.types.pkgs; + }; + }; + config._module.args.unstablePkgs = config.unstable.pkgs; + # FIXME: move it to the system derivation output (overrideAttrs config.system.build.toplevel?) + config.environment.etc."NIXOS-UNSTABLE-VERSION".text = nixos-unstable-version; +} \ No newline at end of file