Hey I have a problem that whatever I try I can’t get the command
sudo nixos-rebuild build --flake .#desktop
to work
building the system configuration...
warning: Git tree '/home/stefan/nixos' is dirty
error:
… while calling the 'seq' builtin
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:322:18:
321| options = checked options;
322| config = checked (removeAttrs config [ "_module" ]);
| ^
323| _module = checked (config._module);
… while evaluating a branch condition
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:261:9:
260| checkUnmatched =
261| if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
| ^
262| let
… in the left operand of the AND (&&) operator
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:261:72:
260| checkUnmatched =
261| if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
| ^
262| let
… in the left operand of the AND (&&) operator
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:261:33:
260| checkUnmatched =
261| if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
| ^
262| let
… while evaluating a branch condition
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:254:12:
253|
254| in if declaredConfig._module.freeformType == null then declaredConfig
| ^
255| # Because all definitions that had an associated option ended in
… from call site
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:242:28:
241| # For definitions that have an associated option
242| declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
| ^
243|
… while calling 'mapAttrsRecursiveCond'
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/attrsets.nix:734:5:
733| # Attribute set to recursively map over.
734| set:
| ^
735| let
… from call site
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:234:33:
233| ({ inherit lib options config specialArgs; } // specialArgs);
234| in mergeModules prefix (reverseList collected);
| ^
235|
… while calling 'reverseList'
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/lists.nix:510:17:
509| */
510| reverseList = xs:
| ^
511| let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;
… from call site
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:229:25:
228| merged =
229| let collected = collectModules
| ^
230| class
… while calling anonymous lambda
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:445:37:
444|
445| in modulesPath: initialModules: args:
| ^
446| filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
… from call site
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:446:7:
445| in modulesPath: initialModules: args:
446| filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
| ^
447|
… while calling 'filterModules'
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:413:36:
412| # modules recursively. It returns the final list of unique-by-key modules
413| filterModules = modulesPath: { disabled, modules }:
| ^
414| let
… while calling anonymous lambda
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:439:31:
438| disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
439| keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
| ^
440| in map (attrs: attrs.module) (builtins.genericClosure {
… from call site
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:400:22:
399| let
400| module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
| ^
401| collectedImports = collectStructuredModules module._file module.key module.imports args;
… while calling anonymous lambda
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:359:11:
358| then
359| m:
| ^
360| if m._class != null -> m._class == class
… from call site
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:400:35:
399| let
400| module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
| ^
401| collectedImports = collectStructuredModules module._file module.key module.imports args;
… while calling 'loadModule'
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:336:53:
335| # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
336| loadModule = args: fallbackFile: fallbackKey: m:
| ^
337| if isFunction m then
… from call site
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:354:14:
353| throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
354| else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
| ^
355|
… while calling 'unifyModuleSyntax'
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:454:34:
453| of ‘options’, ‘config’ and ‘imports’ attributes. */
454| unifyModuleSyntax = file: key: m:
| ^
455| let
… from call site
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:354:59:
353| throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
354| else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
| ^
355|
… while calling 'applyModuleArgsIfFunction'
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:488:39:
487|
488| applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }:
| ^
489| if isFunction f then applyModuleArgs key f args else f;
… from call site
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/modules.nix:489:8:
488| applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }:
489| if isFunction f then applyModuleArgs key f args else f;
| ^
490|
… while calling 'isFunction'
at /nix/store/gsydlhd8sya1wf5prv1p8sg4dd91gna4-source/lib/trivial.nix:458:16:
457| */
458| isFunction = f: builtins.isFunction f ||
| ^
459| (f ? __functor && isFunction (f.__functor f));
error: getting status of '/nix/store/jx33asf8ykz3rxafvx56gq2vhqn14zh5-source/hosts/desktop': No such file or directory
├── flake.lock
├── flake.nix
├── hosts
│ ├── desktop
│ │ ├── configuration.nix
│ │ ├── hardware-configuration.nix
│ │ └── main-user.nix
│ ├── liveiso
│ │ └── configuration.nix
│ └── vmHost
│ ├── configuration.nix
│ ├── hardware-configuration.nix
│ ├── home.nix
│ └── main-user.nix
├── modules
│ ├── default.nix
│ ├── features
│ │ └── power-management.nix
│ ├── home-manager
│ ├── nixos
│ └── services
└── myLib
└── default.nix
# flake.nix
{
# ================================================================ #
# = WELCOME! = #
# ================================================================ #
description = "My NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = {...} @ inputs: let
# super simple boilerplate-reducing
# lib with a bunch of functions
myLib = import ./myLib/default.nix {inherit inputs;};
in
with myLib; {
nixosConfigurations = {
# ===================== NixOS Configurations ===================== #
desktop = mkSystem ./hosts/desktop/configuration.nix;
# vmHost = mkSystem ./hosts/vmHost/configuration.nix;
liveiso = mkSystem ./hosts/liveiso/configuration.nix;
};
nixosModules.default = ./modules;
};
}
# myLib/default.nix
{inputs}: let
myLib = (import ./default.nix) {inherit inputs;};
outputs = inputs.self.outputs;
in rec {
# ================================================================ #
# = My Lib = #
# ================================================================ #
# ======================= Package Helpers ======================== #
pkgsFor = sys: inputs.nixpkgs.legacyPackages.${sys};
# ========================== Buildables ========================== #
mkSystem = config:
inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs myLib;
};
modules = [
config
outputs.nixosModules.default
];
};
mkHome = sys: config:
inputs.home-manager.lib.homeManagerConfiguration {
pkgs = pkgsFor sys;
extraSpecialArgs = {
inherit inputs myLib outputs;
};
modules = [
config
outputs.homeManagerModules.default
];
};
# =========================== Helpers ============================ #
filesIn = dir: (map (fname: dir + "/${fname}")
(builtins.attrNames (builtins.readDir dir)));
fileNameOf = path: (builtins.head (builtins.split "\\." (baseNameOf path)));
# ========================== Extenders =========================== #
# Evaluates nixos/home-manager module and extends it's options / config
extendModule = {path, ...} @ args: {pkgs, ...} @ margs: let
eval =
if (builtins.isString path) || (builtins.isPath path)
then import path margs
else path margs;
evalNoImports = builtins.removeAttrs eval ["imports" "options"];
extra =
if (builtins.hasAttr "extraOptions" args) || (builtins.hasAttr "extraConfig" args)
then [
({...}: {
options = args.extraOptions or {};
config = args.extraConfig or {};
})
]
else [];
in {
imports =
(eval.imports or [])
++ extra;
options =
if builtins.hasAttr "optionsExtension" args
then (args.optionsExtension (eval.options or {}))
else (eval.options or {});
config =
if builtins.hasAttr "configExtension" args
then (args.configExtension (eval.config or evalNoImports))
else (eval.config or evalNoImports);
};
# Applies extendModules to all modules
# modules can be defined in the same way
# as regular imports, or taken from "filesIn"
extendModules = extension: modules:
map
(f: let
name = fileNameOf f;
in (extendModule ((extension name) // {path = f;})))
modules;
# ============================ Shell ============================= #
forAllSystems = pkgs:
inputs.nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(system: pkgs inputs.nixpkgs.legacyPackages.${system});
}