From 864cf63397f848da278172740f08a1074a62e9eb Mon Sep 17 00:00:00 2001 From: albert Date: Tue, 13 Aug 2024 18:41:19 +0900 Subject: [PATCH] Update lib directory, organize things --- flake.nix | 2 +- lib/default.nix | 44 ++++++++------------------------------------ lib/packages.nix | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+), 37 deletions(-) create mode 100644 lib/packages.nix diff --git a/flake.nix b/flake.nix index c0f5a8f9..330214d1 100644 --- a/flake.nix +++ b/flake.nix @@ -50,7 +50,7 @@ inherit (self) outputs; stateVersion = "23.11"; hmStateVersion = "23.11"; - libx = import ./lib { inherit self inputs outputs stateVersion hmStateVersion; }; + libx = import ./lib/default.nix { inherit self inputs outputs stateVersion hmStateVersion; }; in { nixosConfigurations = { # Linode VMs diff --git a/lib/default.nix b/lib/default.nix index c88dc7ff..06564a8d 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -42,10 +42,8 @@ ip ? null, ephemeral ? false, deployment_type ? "containers", - pkgs ? import inputs.${repo} - { inherit system; config.allowUnfree = unfree; hostPlatform = system; }, - pkgs-unstable ? import inputs.nixpkgs-unstable - { inherit system; config.allowUnfree = unfree; hostPlatform = system; } + pkgs ? let packages = (import ./packages.nix { inherit inputs repo system unfree; }); in packages.pkgs, + pkgs-unstable ? let packages = (import ./packages.nix { inherit inputs repo system unfree; }); in packages.pkgs-unstable, }: { bindMounts = lib.mkMerge [ ( import ../nixos/containers/mounts.nix ) @@ -87,16 +85,12 @@ theme ? "default", type ? "default", repo ? "nixpkgs-unstable", + unfree ? true, deployment_type ? "hosts", }: inputs.${repo}.lib.nixosSystem { specialArgs = { inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu system theme self deployment_type; - # Some packages (ie, Vintage Story) I want to keep on unstable no matter what default repo I use - pkgs-unstable = import inputs.nixpkgs-unstable { - inherit system; - config.allowUnfree = true; - hostPlatform = system; - }; + pkgs-unstable = let packages = (import ./packages.nix { inherit inputs repo system unfree; }); in packages.pkgs-unstable; }; modules = [ @@ -124,17 +118,8 @@ specialArgs = { inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu system theme self deployment_type; # Choose whether to pull from stable or unstable - pkgs = import inputs.${repo} { - inherit system; - config.allowUnfree = unfree; - hostPlatform = system; - }; - # Some packages (ie, Vintage Story) I want to keep on unstable no matter what default repo I use - pkgs-unstable = import inputs.nixpkgs-unstable { - inherit system; - config.allowUnfree = unfree; - hostPlatform = system; - }; + pkgs = let packages = (import ./packages.nix { inherit inputs repo system unfree; }); in packages.pkgs; + pkgs-unstable = let packages = (import ./packages.nix { inherit inputs repo system unfree; }); in packages.pkgs-unstable; }; modules = [ @@ -160,21 +145,8 @@ specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu system theme format; # Choose whether to pull from stable or unstable - pkgs = import inputs.${repo} { - inherit system; - config.allowUnfree = unfree; - # For Logseq / Obsidian - config.permittedInsecurePackages = [ "electron-27.3.11" ]; - hostPlatform = system; - }; - # Some packages (ie, Vintage Story) I want to keep on unstable no matter what default repo I use - pkgs-unstable = import inputs.nixpkgs-unstable { - inherit system; - config.allowUnfree = unfree; - # For Logseq / Obsidian - config.permittedInsecurePackages = [ "electron-27.3.11" ]; - hostPlatform = system; - }; + pkgs = let packages = (import ./packages.nix { inherit inputs repo system unfree; }); in packages.pkgs; + pkgs-unstable = let packages = (import ./packages.nix { inherit inputs repo system unfree; }); in packages.pkgs-unstable; }; system = system; format = format; diff --git a/lib/packages.nix b/lib/packages.nix new file mode 100644 index 00000000..66ba156e --- /dev/null +++ b/lib/packages.nix @@ -0,0 +1,20 @@ +{ inputs, system, unfree, repo, ... }: { + # Choose whether to pull from stable or unstable + pkgs = (import inputs.${repo} { + inherit system; + config = { + allowUnfree = unfree; + permittedInsecurePackages = [ "electron-27.3.11" ]; + }; + hostPlatform = system; + }); + # Some packages (ie, Vintage Story) I want to keep on unstable no matter what default repo I use + pkgs-unstable = (import inputs.nixpkgs-unstable { + inherit system; + config = { + allowUnfree = unfree; + permittedInsecurePackages = [ "electron-27.3.11" ]; + }; + hostPlatform = system; + }); +}