Compare commits

...

3 Commits

Author SHA1 Message Date
bde6ae6da1
system: replace custom args with flakeArgs and flakeConfig 2025-03-01 14:52:49 -05:00
004770c410
flake: move devShell to perSystem, add formatter 2025-02-28 19:16:21 -05:00
ee9f7ff199
mitigations: pin mopidy
pinned to some random version from several months ago because of bug
that causes playback freezing
2025-02-28 19:16:07 -05:00
17 changed files with 163 additions and 81 deletions

17
flake.lock generated
View File

@ -1179,6 +1179,22 @@
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
} }
}, },
"nixpkgs-mopidy": {
"locked": {
"lastModified": 1734856068,
"narHash": "sha256-Q+CB1ajsJg4Z9HGHTBAGY1q18KpnnkmF/eCTLUY6FQ0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "93ff48c9be84a76319dac293733df09bbbe3f25c",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "93ff48c9be84a76319dac293733df09bbbe3f25c",
"type": "github"
}
},
"nixpkgs-nix-du": { "nixpkgs-nix-du": {
"locked": { "locked": {
"lastModified": 1722785290, "lastModified": 1722785290,
@ -1335,6 +1351,7 @@
"nix-wsl": "nix-wsl", "nix-wsl": "nix-wsl",
"nixfiles-assets": "nixfiles-assets", "nixfiles-assets": "nixfiles-assets",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"nixpkgs-mopidy": "nixpkgs-mopidy",
"nixpkgs-nix-du": "nixpkgs-nix-du", "nixpkgs-nix-du": "nixpkgs-nix-du",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"rust-overlay": "rust-overlay_2", "rust-overlay": "rust-overlay_2",

View File

@ -9,6 +9,7 @@
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-nix-du.url = "github:NixOS/nixpkgs/c933cf4698e5189b35dd83bf4d7a81aef16d464a"; nixpkgs-nix-du.url = "github:NixOS/nixpkgs/c933cf4698e5189b35dd83bf4d7a81aef16d464a";
nixpkgs-mopidy.url = "github:NixOS/nixpkgs/93ff48c9be84a76319dac293733df09bbbe3f25c";
# this seems to be a popular way to declare systems # this seems to be a popular way to declare systems
systems.url = "github:nix-systems/default"; systems.url = "github:nix-systems/default";
@ -150,6 +151,7 @@
perSystem = { perSystem = {
config, config,
pkgs, pkgs,
self',
... ...
}: { }: {
treefmt = { treefmt = {
@ -157,6 +159,32 @@
alejandra.enable = true; alejandra.enable = true;
}; };
}; };
devShells = {
ci = pkgs.mkShell {
buildInputs = with pkgs; [
nix-update
nix-fast-build
];
};
default = let
formatter =
pkgs.runCommandNoCC "flake-formatter" {
formatter = lib.getExe self'.formatter;
} ''
mkdir -p $out/bin
ln -s "$formatter" "$out/bin/formatter"
'';
in
pkgs.mkShell {
buildInputs = with pkgs; [
alejandra
nix-update
formatter
inputs.agenix.packages.${system}.default
];
};
};
}; };
nixfiles = { nixfiles = {
@ -249,24 +277,6 @@
}; };
# }}} # }}}
in { in {
devShells = eachSystem (system: let
pkgs = import nixpkgs-unstable {inherit system;};
in {
ci = pkgs.mkShell {
buildInputs = with pkgs; [
nix-update
nix-fast-build
];
};
default = pkgs.mkShell {
buildInputs = with pkgs; [
alejandra
nix-update
inputs.agenix.packages.${system}.default
];
};
});
# nix flake modules are meant to be portable so we cannot rely on # nix flake modules are meant to be portable so we cannot rely on
# (extraS|s)pecialArgs to pass variables # (extraS|s)pecialArgs to pass variables
nixosModules = (import ./modules/nixos) moduleInputs; nixosModules = (import ./modules/nixos) moduleInputs;

View File

@ -6,7 +6,7 @@
inputs, inputs,
self, self,
... ...
}: let } @ flakeArgs: let
cfg = config.nixfiles.systems; cfg = config.nixfiles.systems;
inherit inherit
(lib) (lib)
@ -227,14 +227,22 @@ in {
++ lib.optional config.wsl wslModule; ++ lib.optional config.wsl wslModule;
extraConfig = { extraConfig = {
inherit (config) system modules; inherit (config) system modules;
# TODO get rid of specialArgs and pass things as a module specialArgs = {
specialArgs = let # TODO this is temporary, i prefer to not use specialArgs because
inherit (self) outputs; # it can't be exported. these are still better than my clunky
in { # "vars" arg that i would arbitrarily add things to.
inherit inputs outputs; #
inherit (outerConfig.nixfiles) vars; # we need to merge all of the module args like this because the
# module evaluator only calls each module with the args it asks
# for, but we explicitly want *all* args to be made available.
flakeArgs = outerConfig._module.args // outerConfig._module.specialArgs // flakeArgs;
# still unsure of what the best way to deal with this is. i can
# probably pass this submodule's args for a fairly clean way to
# pass it, but i'd want to refactor it because config.nixpkgs and
# config.home-manager.input are named inconsistently
inherit (config) nixpkgs; inherit (config) nixpkgs;
inherit (config.home-manager) input; home-manager = config.home-manager.input;
}; };
}; };
result = config.nixpkgs.lib.nixosSystem config.extraConfig; result = config.nixpkgs.lib.nixosSystem config.extraConfig;

View File

@ -2,9 +2,11 @@
pkgs, pkgs,
config, config,
lib, lib,
vars, flakeConfig,
... ...
}: { }: let
inherit (flakeConfig.nixfiles) vars;
in {
config = { config = {
networking.hostName = "nixos-wsl"; networking.hostName = "nixos-wsl";

View File

@ -6,7 +6,6 @@
config, config,
lib, lib,
pkgs, pkgs,
inputs,
... ...
}: { }: {
imports = [ imports = [

View File

@ -6,7 +6,6 @@
config, config,
lib, lib,
pkgs, pkgs,
vars,
... ...
}: { }: {
imports = [ imports = [

View File

@ -12,7 +12,7 @@
pkgsStable = import nixfiles.inputs.nixpkgs.outPath {inherit (prev) system;}; pkgsStable = import nixfiles.inputs.nixpkgs.outPath {inherit (prev) system;};
updateTime = nixfiles.inputs.nixpkgs-unstable.lastModified; updateTime = nixfiles.inputs.nixpkgs-unstable.lastModified;
inherit (final) lib callPackage fetchFromGitHub; inherit (final) callPackage fetchFromGitHub;
inherit inherit
(lib) (lib)
recurseIntoAttrs recurseIntoAttrs
@ -55,7 +55,8 @@
prev.gimp-with-plugins.override {inherit plugins;}; prev.gimp-with-plugins.override {inherit plugins;};
# this also causes an infinite recursion and i have no idea why # this also causes an infinite recursion and i have no idea why
# in nixfiles.inputs.nixpkgs.lib.filterAttrs (k: v: v != null) { # in nixfiles.inputs.nixpkgs.lib.filterAttrs (k: v: v != null) {
in { in
{
nix-du = let nix-du = let
old = prev.nix-du; old = prev.nix-du;
new = (pkgsFromInput "nixpkgs-nix-du").nix-du; new = (pkgsFromInput "nixpkgs-nix-du").nix-du;
@ -83,7 +84,42 @@
inherit (prev) redlib; inherit (prev) redlib;
in in
pickNewer redlib-new redlib; pickNewer redlib-new redlib;
}; }
// (
lib.genAttrs [
"mopidyPackages"
"mopidy"
"mopidy-bandcamp"
"mopidy-iris"
"mopidy-jellyfin"
"mopidy-local"
"mopidy-moped"
"mopidy-mopify"
"mopidy-mpd"
"mopidy-mpris"
"mopidy-muse"
"mopidy-musicbox-webclient"
"mopidy-notify"
"mopidy-podcast"
"mopidy-scrobbler"
"mopidy-somafm"
"mopidy-soundcloud"
"mopidy-spotify"
"mopidy-subidy"
"mopidy-tidal"
"mopidy-tunein"
"mopidy-youtube"
"mopidy-ytmusic"
] (name: let
pkgs-mopidy = (import inputs.nixpkgs-mopidy) {inherit (prev) system;};
unstable = prev."${name}";
stable = pkgs-mopidy."${name}";
now = 1740786429;
in
# pin for at least 90 days because who knows when this will be fixed
# https://github.com/mopidy/mopidy/issues/2183
hold now 90 stable unstable)
);
in { in {
config.flake.overlays.mitigations = overlay; config.flake.overlays.mitigations = overlay;
} }

View File

@ -3,10 +3,11 @@
lib, lib,
config, config,
options, options,
inputs, flakeArgs,
nixpkgs, nixpkgs,
... ...
}: let }: let
inherit (flakeArgs) inputs;
cfg = config.nixfiles.common.nix; cfg = config.nixfiles.common.nix;
in { in {
options.nixfiles.common.nix = { options.nixfiles.common.nix = {

View File

@ -3,9 +3,9 @@
config, config,
lib, lib,
options, options,
flakeArgs,
nixpkgs, nixpkgs,
home-manager, home-manager,
inputs,
utils, utils,
... ...
} @ args: } @ args:
@ -14,8 +14,15 @@
# inputs/outputs/overlays/etc into scope. this might even make nixfiles # inputs/outputs/overlays/etc into scope. this might even make nixfiles
# portable (it still shouldn't be imported by other flakes probably) # portable (it still shouldn't be imported by other flakes probably)
let let
inherit (flakeArgs) inputs;
cfg = config.nixfiles; cfg = config.nixfiles;
flakeType = cfg.lib.types.flake; flakeType = cfg.lib.types.flake;
mkReadOnlyOption = {...} @ args:
lib.mkOption ({
readOnly = true;
}
// args);
in { in {
imports = [ imports = [
./common ./common
@ -35,7 +42,15 @@ in {
inputs.lanzaboote.nixosModules.lanzaboote inputs.lanzaboote.nixosModules.lanzaboote
./stylix.nix # imports inputs.stylix ./stylix.nix # imports inputs.stylix
]; ];
config = {}; config = {
_module.args.flakeConfig = flakeArgs.config;
};
options.debug = {
args = mkReadOnlyOption {
description = "all module args";
default = config._module.args // config._module.specialArgs // args;
};
};
options.nixfiles = { options.nixfiles = {
meta.wayland = lib.mkOption { meta.wayland = lib.mkOption {
description = "Whether to prefer wayland applications and configuration"; description = "Whether to prefer wayland applications and configuration";
@ -44,12 +59,6 @@ in {
type = lib.types.bool; type = lib.types.bool;
}; };
utils = lib.mkOption {
description = "nixpkgs `utils` argument passthrough";
default = utils;
readOnly = true;
};
workarounds.nvidiaPrimary = lib.mkOption { workarounds.nvidiaPrimary = lib.mkOption {
description = "Whether to enable workarounds for NVIDIA as the primary GPU"; description = "Whether to enable workarounds for NVIDIA as the primary GPU";
default = false; default = false;

View File

@ -2,11 +2,12 @@
config, config,
lib, lib,
pkgs, pkgs,
inputs, flakeArgs,
... ...
}: let }: let
cfg = config.nixfiles.hardware.sound; inherit (flakeArgs) inputs;
inherit (lib) optionals mkEnableOption mkIf mkDefault; inherit (lib) optionals mkEnableOption mkIf mkDefault;
cfg = config.nixfiles.hardware.sound;
in { in {
# Enable sound. # Enable sound.
# sound.enable = true; # sound.enable = true;

View File

@ -2,9 +2,11 @@
config, config,
lib, lib,
pkgs, pkgs,
inputs, flakeArgs,
... ...
}: { }: let
inherit (flakeArgs) inputs;
in {
imports = [ imports = [
inputs.nix-minecraft.nixosModules.minecraft-servers inputs.nix-minecraft.nixosModules.minecraft-servers
]; ];

View File

@ -1,11 +1,10 @@
{ {
pkgs, pkgs,
config, config,
lib, flakeArgs,
inputs,
nixpkgs,
... ...
}: let }: let
inherit (flakeArgs) inputs;
p5 = config.services.xserver.desktopManager.plasma5.enable; p5 = config.services.xserver.desktopManager.plasma5.enable;
p6 = config.services.desktopManager.plasma6.enable; p6 = config.services.desktopManager.plasma6.enable;

View File

@ -2,7 +2,6 @@
config, config,
lib, lib,
pkgs, pkgs,
inputs,
... ...
}: let }: let
cfg = config.nixfiles.packageSets.gaming; cfg = config.nixfiles.packageSets.gaming;

View File

@ -2,9 +2,6 @@
config, config,
lib, lib,
pkgs, pkgs,
options,
inputs,
outputs,
... ...
} @ args: let } @ args: let
cfg = config.nixfiles.profile.base; cfg = config.nixfiles.profile.base;

View File

@ -2,10 +2,10 @@
config, config,
lib, lib,
pkgs, pkgs,
outputs, flakeConfig,
vars,
... ...
} @ args: let } @ args: let
inherit (flakeConfig.nixfiles) vars;
cfg = config.nixfiles.programs.adb; cfg = config.nixfiles.programs.adb;
in { in {
options.nixfiles.programs.adb = { options.nixfiles.programs.adb = {

View File

@ -2,9 +2,10 @@
lib, lib,
pkgs, pkgs,
config, config,
inputs, flakeArgs,
... ...
}: let }: let
inherit (flakeArgs) inputs;
cfg = config.nixfiles.sessions.hyprland; cfg = config.nixfiles.sessions.hyprland;
flake-package = inputs.hyprland.packages.${pkgs.system}.hyprland; flake-package = inputs.hyprland.packages.${pkgs.system}.hyprland;
flake-portal = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland; flake-portal = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland;

View File

@ -2,9 +2,11 @@
pkgs, pkgs,
config, config,
lib, lib,
inputs, flakeArgs,
... ...
} @ args: { } @ args: let
inherit (flakeArgs) inputs;
in {
imports = [inputs.stylix.nixosModules.stylix]; imports = [inputs.stylix.nixosModules.stylix];
config = { config = {