From 0c9459d351e777e30204d67f1a0d8e31c3431087 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 16:31:47 -0400 Subject: [PATCH] Use variables for my name --- flake.nix | 100 +++++++++++++++++--------------- modules/darwin/default.nix | 9 ++- modules/nixos/configuration.nix | 15 ++--- 3 files changed, 68 insertions(+), 56 deletions(-) diff --git a/flake.nix b/flake.nix index 4d354fe7..fccc0ebf 100644 --- a/flake.nix +++ b/flake.nix @@ -22,59 +22,67 @@ }; # end inputs outputs = { self, nixpkgs, nix-darwin, home-manager, nix-homebrew, ... }: { - nixosConfigurations.rainbow-planet = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./modules/nixos/configuration.nix - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users."gene".imports = [ - ./modules/home-manager - ./modules/nixos/dconf.nix - ]; - }; - } - ]; + nixosConfigurations = let + user = "gene"; + in { + rainbow-planet = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./modules/nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.${user}.imports = [ + ./modules/home-manager + ./modules/nixos/dconf.nix + ]; + }; + } + ]; + }; # end rainbow-planet }; # end nixosConfigurations # This is only set to work with x86 macOS right now... that will need to be updated - darwinConfigurations.Blue-Rock = nix-darwin.lib.darwinSystem { - system = "x86_64-darwin"; - pkgs = import nixpkgs { + darwinConfigurations = let + user = "gene.liverman"; + in { + Blue-Rock = nix-darwin.lib.darwinSystem { system = "x86_64-darwin"; - config.allowUnfree = true; - }; - modules = [ - nix-homebrew.darwinModules.nix-homebrew - { - nix-homebrew = { - # Install Homebrew under the default prefix - enable = true; + pkgs = import nixpkgs { + system = "x86_64-darwin"; + config.allowUnfree = true; + }; + modules = [ + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + # Install Homebrew under the default prefix + enable = true; - # User owning the Homebrew prefix - user = "gene.liverman"; + # User owning the Homebrew prefix + user = "${user}"; - # Automatically migrate existing Homebrew installations - autoMigrate = true; - }; - } + # Automatically migrate existing Homebrew installations + autoMigrate = true; + }; + } - ./modules/darwin + ./modules/darwin - home-manager.darwinModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users."gene.liverman".imports = [ - ./modules/home-manager - ]; - }; - } - ]; # end modules - }; # end of darwinConfigurations.Blue-Rock + home-manager.darwinModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.${user}.imports = [ + ./modules/home-manager + ]; + }; + } + ]; # end modules + }; # end Blue-Rock + }; # end darwinConfigurations }; } diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 7e7f24be..fc6a1e59 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,4 +1,6 @@ -{ pkgs, ... }: { +{ pkgs, ... }: let + user = "gene.liverman"; +in { system.stateVersion = 4; environment = { @@ -110,6 +112,7 @@ "flakes" "nix-command" ]; + trusted-users = [ "@admin" "${user}" ]; }; extraOptions = '' # Generated by https://github.com/DeterminateSystems/nix-installer, version 0.11.0. @@ -121,8 +124,8 @@ services.nix-daemon.enable = true; - users.users."gene.liverman" = { - home = "/Users/gene.liverman"; + users.users.${user} = { + home = "/Users/${user}"; shell = pkgs.zsh; }; } diff --git a/modules/nixos/configuration.nix b/modules/nixos/configuration.nix index aca022ca..b6a491ef 100644 --- a/modules/nixos/configuration.nix +++ b/modules/nixos/configuration.nix @@ -2,9 +2,10 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, ... }: - -{ +{ config, pkgs, ... }:let + user = "gene"; + hostname = "rainbow-planet"; +in { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix @@ -14,7 +15,7 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - networking.hostName = "rainbow-planet"; # Define your hostname. + networking.hostName = "${hostname}"; # Define your hostname. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # Configure network proxy if necessary @@ -83,7 +84,7 @@ # services.xserver.libinput.enable = true; # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.gene = { + users.users.${user} = { isNormalUser = true; description = "Gene Liverman"; extraGroups = [ "networkmanager" "wheel" "dialout" ]; @@ -139,7 +140,7 @@ enable = true; # Certain features, including CLI integration and system authentication support, # require enabling PolKit integration on some desktop environments (e.g. Plasma). - polkitPolicyOwners = [ "gene" ]; + polkitPolicyOwners = [ "${user}" ]; }; # List services that you want to enable: @@ -160,7 +161,7 @@ # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = "23.05"; # Did you read the comment? - nix.settings.allowed-users = [ "gene" ]; + nix.settings.allowed-users = [ "${user}" ]; nix.settings.experimental-features = [ "flakes" "nix-command"