From 24d658d4879cbf41c78f75a326e3e59de979844c Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Sat, 16 Dec 2023 23:37:15 -0500 Subject: [PATCH] Cleanup the flake a little bit --- README.md | 98 +++++++++++++++++++++++++++++++++++++++++++++---------- flake.nix | 45 +++++++++---------------- 2 files changed, 97 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index baeaed4..c28c3e2 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,91 @@ # Dots -This repo historically contained my dot files and is now transitioning to being a Nix flake that manages my dot files and the things that consume them. Things are changing a lot right now, but historically symlinked files are still in `link/`. Most all the other old stuff is now tucked away under `legacy/` to get it out of the way until I decide what is and isn't needed. +This repo is a Nix flake that manages most of my setup on macOS and fully manages machines I have that run NixOS as their operating system. -The new Nix bits are driven by `flake.nix` which pulls in things under `modules/`. Initial support is for both x86 macOS and NixOS. New stuff is structured like so, at least for now: +## Flake structure + +The Nix bits are driven by `flake.nix` which pulls in things under `modules/`. Initial support is for both x86 macOS and NixOS. The flake is structured like so: + +- description: a human readable description of this flake +- inputs: all the places things are pulled from +- outputs: + - all the outputs from the inputs + - a `let` ... `in` block that contains: + - `darwinHostConfig` which takes 3 params and pulls in all the things needed to use Nix on a macOS host + - `nixosHostConfig` which takes 3 params and pulls in all the things needed to configure a NixOS host + - the body of outputs that contains: + - `darwinConfigurations` contains an entry for each macOS host set to the results of a call to `darwinHostConfig` with values for each of the required parameters + - `nixosConfigurations` contains an entry for each nixOS host set to the results of a call to `nixosHostConfig` with values for each of the required parameters + +The parameters on `darwinHostConfig` & `nixosHostConfig` are: + +- `system:` the system definition to use for nixpkgs +- `hostname:` the hostname of the machine being configured +- `username:` the username being configured on the host (all code currently assumes there is a single human user managed by Nix) + +## Repo structure + +The Nix stuff is structured like so, at least for now: ```bash -$ tree . -I legacy* -I link* +$ tree . -I legacy* -I link* --gitignore --dirsfirst . -├── flake.lock -├── flake.nix -├── LICENSE ├── modules -│ ├── darwin -│ │ └── default.nix -│ ├── home-manager -│ │ └── default.nix -│ ├── linux -│ └── nixos -│ ├── dconf.nix -│ ├── default.nix -│ └── hardware-configuration.nix +│   ├── home-manager +│   │   ├── common +│   │   │   ├── linux-apps +│   │   │   │   ├── tilix.nix +│   │   │   │   ├── waybar.nix +│   │   │   │   └── xfce4-terminal.nix +│   │   │   ├── all-cli.nix +│   │   │   ├── all-darwin.nix +│   │   │   ├── all-gui.nix +│   │   │   └── all-linux.nix +│   │   ├── files +│   │   │   ├── tilix +│   │   │   │   └── Beanbag-Mathias.json +│   │   │   ├── waybar +│   │   │   │   ├── config +│   │   │   │   └── style.css +│   │   │   ├── xfce4 +│   │   │   │   └── terminal +│   │   │   │   ├── accels.scm +│   │   │   │   └── terminalrc +│   │   │   └── Microsoft.PowerShell_profile.ps1 +│   │   └── hosts +│   │   ├── Blue-Rock +│   │   │   └── gene.liverman.nix +│   │   ├── nixnuc +│   │   │   └── gene.nix +│   │   └── rainbow-planet +│   │   └── gene.nix +│   ├── hosts +│   │   ├── darwin +│   │   │   └── Blue-Rock +│   │   │   └── default.nix +│   │   └── nixos +│   │   ├── nixnuc +│   │   │   ├── default.nix +│   │   │   └── hardware-configuration.nix +│   │   └── rainbow-planet +│   │   ├── default.nix +│   │   └── hardware-configuration.nix +│   └── system +│   └── common +│   ├── linux +│   │   └── internationalisation.nix +│   ├── all-darwin.nix +│   └── all-nixos.nix +├── LICENSE ├── README.md -└── Vagrantfile +├── Vagrantfile +├── flake.lock +└── flake.nix + +23 directories, 29 files -6 directories, 10 files ``` + +## Historical bits + +This repo historically contained my dot files. Historically symlinked files are still in `link/`. Most all the other old stuff is now tucked away under `legacy/` to get it out of the way until I decide what is and isn't needed. diff --git a/flake.nix b/flake.nix index 5249ca0..178f18f 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ nixpkgs.url = "github:nixos/nixpkgs"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - # Controls system level software and settings including fonts + # Controls system level software and settings including fonts on macOS nix-darwin = { url = "github:lnl7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; @@ -35,44 +35,34 @@ }; # end inputs outputs = inputs@{ self, nixpkgs, nixpkgs-unstable, nix-darwin, home-manager, nix-homebrew, disko, genebean-omp-themes, ... }: let - inputs = { inherit disko home-manager nixpkgs nixpkgs-unstable nix-darwin; }; # creates a macOS system config - darwinSystem = system: hostname: username: nix-darwin.lib.darwinSystem { + darwinHostConfig = system: hostname: username: nix-darwin.lib.darwinSystem { pkgs = import nixpkgs { inherit system; config = { allowUnfree = true; - permittedInsecurePackages = [ - "python-2.7.18.7" - ]; + permittedInsecurePackages = [ "python-2.7.18.7" ]; }; }; specialArgs = { inherit inputs username hostname; }; modules = [ - nix-homebrew.darwinModules.nix-homebrew - { + nix-homebrew.darwinModules.nix-homebrew { nix-homebrew = { - # Install Homebrew under the default prefix - enable = true; - - # User owning the Homebrew prefix - user = "${username}"; - - # Automatically migrate existing Homebrew installations - autoMigrate = true; + enable = true; # Install Homebrew under the default prefix + user = "${username}"; # User owning the Homebrew prefix + autoMigrate = true; # Automatically migrate existing Homebrew installations }; } - home-manager.darwinModules.home-manager - { + home-manager.darwinModules.home-manager { home-manager = { + extraSpecialArgs = { inherit genebean-omp-themes; }; useGlobalPkgs = true; useUserPackages = true; users.${username}.imports = [ ./modules/home-manager/hosts/${hostname}/${username}.nix ]; - extraSpecialArgs = { inherit genebean-omp-themes; }; }; } @@ -82,27 +72,24 @@ }; # end darwinSystem # creates a nixos system config - nixosSystem = system: hostname: username: nixpkgs.lib.nixosSystem { + nixosHostConfig = system: hostname: username: nixpkgs.lib.nixosSystem { pkgs = import nixpkgs { inherit system; config = { allowUnfree = true; - permittedInsecurePackages = [ - "electron-21.4.4" # Well, this sucks, hopefully a fixed version is available soon... - ]; + permittedInsecurePackages = [ "electron-21.4.4" ]; }; }; specialArgs = { inherit inputs username hostname; }; modules = [ - home-manager.nixosModules.home-manager - { + home-manager.nixosModules.home-manager { home-manager = { + extraSpecialArgs = { inherit genebean-omp-themes; }; useGlobalPkgs = true; useUserPackages = true; users.${username}.imports = [ ./modules/home-manager/hosts/${hostname}/${username}.nix ]; - extraSpecialArgs = { inherit genebean-omp-themes; }; }; } @@ -113,12 +100,12 @@ in { darwinConfigurations = { - Blue-Rock = darwinSystem "x86_64-darwin" "Blue-Rock" "gene.liverman"; + Blue-Rock = darwinHostConfig "x86_64-darwin" "Blue-Rock" "gene.liverman"; }; nixosConfigurations = { - nixnuc = nixosSystem "x86_64-linux" "nixnuc" "gene"; - rainbow-planet = nixosSystem "x86_64-linux" "rainbow-planet" "gene"; + nixnuc = nixosHostConfig "x86_64-linux" "nixnuc" "gene"; + rainbow-planet = nixosHostConfig "x86_64-linux" "rainbow-planet" "gene"; }; }; }