Merge pull request #322 from genebean/passing-variables-around

Pass hostname and username to modules
This commit is contained in:
Gene Liverman 2023-12-16 11:06:41 -05:00 committed by GitHub
commit ce3edc74b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 41 deletions

32
flake.lock generated
View file

@ -3,16 +3,16 @@
"brew-src": { "brew-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1690184446, "lastModified": 1694443293,
"narHash": "sha256-fGjvNY6ON/cdExCfwhfqmHzoxs3AZ0sev7vyBHfPGJo=", "narHash": "sha256-wBjbF2RRFyD4lN7ie98VnggmNBwAPv/dg2U+w5mUyuM=",
"owner": "Homebrew", "owner": "Homebrew",
"repo": "brew", "repo": "brew",
"rev": "3b3300546b5a4e40b74f4ee33cf225cca280defe", "rev": "4afb8e5602f3ecc9edf67a44257d8eceeaa8a108",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "Homebrew", "owner": "Homebrew",
"ref": "4.1.1", "ref": "4.1.11",
"repo": "brew", "repo": "brew",
"type": "github" "type": "github"
} }
@ -78,11 +78,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1694375657, "lastModified": 1702735279,
"narHash": "sha256-32X8dcty4vPXx+D4yJPQZBo5hJ1NQikALhevGv6elO4=", "narHash": "sha256-SztEzDOE/6bDNnWWvnRbSHPVrgewLwdSei1sxoZFejM=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "f7848d3e5f15ed02e3f286029697e41ee31662d7", "rev": "e9b9ecef4295a835ab073814f100498716b05a96",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -98,11 +98,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1694497842, "lastModified": 1700795494,
"narHash": "sha256-z03v/m0OwcLBok97KcUgMl8ZFw5Xwsi2z+n6nL7JdXY=", "narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "4496ab26628c5f43d2a5c577a06683c753e32fe2", "rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -137,11 +137,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1690495710, "lastModified": 1695057498,
"narHash": "sha256-7yF5A16Ayorrpcal74mRB1EqwUAHfXnoCIgDvj+ylgo=", "narHash": "sha256-wn3j7u5tOgLLbNxZC542rJiP5iX323m+CoGPMgPOxp4=",
"owner": "zhaofengli-wip", "owner": "zhaofengli-wip",
"repo": "nix-homebrew", "repo": "nix-homebrew",
"rev": "d2738b78fd0f304f5a7ed4764b736ed2c7169b94", "rev": "6ab33c5e9249e74401144a7c667d96a757c5d341",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -197,11 +197,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1694459622, "lastModified": 1702735365,
"narHash": "sha256-PcbBuRJKFxgb+CUQ3sliI5oRaKHHAV+OSTv6GPAccEA=", "narHash": "sha256-PqGFt/SH8WHzuvlgRHrvRjYrafGV7A2S1mfAMnLNol8=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "bb446a19f77e8d1d0c5ada7069d21a001442fc73", "rev": "db6ce8b1a2735932a19575958c1be4b3b62662df",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -38,16 +38,17 @@
inputs = { inherit disko home-manager nixpkgs nixpkgs-unstable nix-darwin; }; inputs = { inherit disko home-manager nixpkgs nixpkgs-unstable nix-darwin; };
# creates a macOS system config # creates a macOS system config
darwinSystem = system: hostName: username: nix-darwin.lib.darwinSystem { darwinSystem = system: hostname: username: nix-darwin.lib.darwinSystem {
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
config = { config = {
allowUnfree = true; allowUnfree = true;
permittedInsecurePackages = [ permittedInsecurePackages = [
"python-2.7.18.6" "python-2.7.18.7"
]; ];
}; };
}; };
specialArgs = { inherit inputs username hostname; };
modules = [ modules = [
nix-homebrew.darwinModules.nix-homebrew nix-homebrew.darwinModules.nix-homebrew
{ {
@ -77,12 +78,12 @@
} }
./modules/common/darwin/all-hosts.nix ./modules/common/darwin/all-hosts.nix
./modules/hosts/darwin/${hostName} # ip address, host specific stuff ./modules/hosts/darwin/${hostname} # ip address, host specific stuff
]; # end modules ]; # end modules
}; # end darwinSystem }; # end darwinSystem
# creates a nixos system config # creates a nixos system config
nixosSystem = system: hostName: username: nixpkgs.lib.nixosSystem { nixosSystem = system: hostname: username: nixpkgs.lib.nixosSystem {
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
config = { config = {
@ -92,6 +93,7 @@
]; ];
}; };
}; };
specialArgs = { inherit inputs username hostname; };
modules = [ modules = [
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
@ -107,7 +109,7 @@
} }
./modules/common/nixos/all-hosts.nix ./modules/common/nixos/all-hosts.nix
./modules/hosts/nixos/${hostName} # ip address, host specific stuff ./modules/hosts/nixos/${hostname} # ip address, host specific stuff
]; ];
}; # end nixosSystem }; # end nixosSystem

View file

@ -1,6 +1,4 @@
{ pkgs, ... }: let { pkgs, hostname, username, ... }: {
username = "gene.liverman";
in {
environment = { environment = {
shells = with pkgs; [ bash zsh ]; shells = with pkgs; [ bash zsh ];
loginShell = pkgs.zsh; loginShell = pkgs.zsh;
@ -68,6 +66,8 @@ in {
}; };
}; };
networking.hostName = "${hostname}";
nix = { nix = {
settings = { settings = {
bash-prompt-prefix = "(nix:$name)\040"; bash-prompt-prefix = "(nix:$name)\040";

View file

@ -1,4 +1,4 @@
{ config, pkgs, ... }: { { config, pkgs, hostname, username, ... }: {
imports = [ imports = [
./internationalisation.nix ./internationalisation.nix
]; ];
@ -26,7 +26,10 @@
}) })
]; ];
networking.hostName = "${hostname}";
nix.settings = { nix.settings = {
allowed-users = [ "${username}" ];
experimental-features = [ experimental-features = [
"flakes" "flakes"
"nix-command" "nix-command"

View file

@ -45,12 +45,15 @@
theme = "Catppuccin-frappe"; theme = "Catppuccin-frappe";
}; };
themes = { themes = {
Catppuccin-frappe = builtins.readFile (pkgs.fetchFromGitHub { Catppuccin-frappe = {
src = pkgs.fetchFromGitHub {
owner = "catppuccin"; owner = "catppuccin";
repo = "bat"; repo = "bat";
rev = "ba4d16880d63e656acced2b7d4e034e4a93f74b1"; rev = "ba4d16880d63e656acced2b7d4e034e4a93f74b1";
hash = "sha256-6WVKQErGdaqb++oaXnY3i6/GuH2FhTgK0v4TN4Y0Wbw="; hash = "sha256-6WVKQErGdaqb++oaXnY3i6/GuH2FhTgK0v4TN4Y0Wbw=";
} + "/Catppuccin-frappe.tmTheme"); };
file = "Catppuccin-frappe.tmTheme";
};
}; };
}; };
eza.enable = true; eza.enable = true;

View file

@ -1,7 +1,4 @@
{ config, pkgs, ... }: let { config, pkgs, username, ... }: {
username = "gene";
hostname = "rainbow-planet";
in {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
@ -39,12 +36,9 @@ in {
]; ];
networking = { networking = {
hostName = "${hostname}";
networkmanager.enable = true; networkmanager.enable = true;
}; };
nix.settings.allowed-users = [ "${username}" ];
programs = { programs = {
_1password.enable = true; _1password.enable = true;
_1password-gui = { _1password-gui = {