From 314b1104562fa7cf7b2945cf47c5ad49e4b99a0e Mon Sep 17 00:00:00 2001 From: Benson Chu Date: Mon, 2 Sep 2024 11:20:44 -0500 Subject: [PATCH] Warn about things not being set --- common/configuration.nix | 4 ++-- common/flake-location.nix | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/common/configuration.nix b/common/configuration.nix index f7d3c9f..ce10f1f 100644 --- a/common/configuration.nix +++ b/common/configuration.nix @@ -2,7 +2,7 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ inputs, config, pkgs, ... }: +{ inputs, config, pkgs, lib, ... }: let system = "x86_64-linux"; in @@ -35,7 +35,7 @@ in nixPath = [ "/home/benson/.nix-defexpr/channels" "nixpkgs=${inputs.nixpkgs}" - "nixos-config=${config.my.flakeLocation}/hosts/${config.networking.hostName}/configuration.nix" + config.my.nixosConfigLocation "/nix/var/nix/profiles/per-user/root/channels"]; # MY GOD, this is what is used for nix develop, nix run, etc. diff --git a/common/flake-location.nix b/common/flake-location.nix index 4ac37fd..c6ad10a 100644 --- a/common/flake-location.nix +++ b/common/flake-location.nix @@ -1,13 +1,24 @@ { inputs, config, lib, pkgs, ... }: -let - system = "x86_64-linux"; -in { options = { my.flakeLocation = lib.mkOption { - default = "/etc/nixos/"; + default = null; description = "Location of nixos flake for config"; + type = lib.types.nullOr lib.types.path; + }; + + my.nixosConfigLocation = lib.mkOption { + # default = "/etc/nixos/"; + internal = true; + description = "Location of nixos configuration"; type = lib.types.path; }; }; + config = { + my.nixosConfigLocation = + if (config.my.flakeLocation != null) + then "${config.my.flakeLocation}/hosts/${config.networking.hostName}/configuration.nix" + else lib.warn "Didn't set 'my.flakeLocation', NIX_PATH functionality will degrade a little" + "${inputs.self}/hosts/${config.networking.hostName}/configuration.nix"; + }; }