Cleanup the flake a little bit

This commit is contained in:
Gene Liverman 2023-12-16 23:37:15 -05:00
parent be7ef7ec7e
commit 24d658d487
2 changed files with 97 additions and 46 deletions

View file

@ -1,27 +1,91 @@
# Dots # 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 ```bash
$ tree . -I legacy* -I link* $ tree . -I legacy* -I link* --gitignore --dirsfirst
. .
├── flake.lock
├── flake.nix
├── LICENSE
├── modules ├── modules
│ ├── darwin │   ├── home-manager
│ │ └── default.nix │   │   ├── common
│ ├── home-manager │   │   │   ├── linux-apps
│ │ └── default.nix │   │   │   │   ├── tilix.nix
│ ├── linux │   │   │   │   ├── waybar.nix
│ └── nixos │   │   │   │   └── xfce4-terminal.nix
│ ├── dconf.nix │   │   │   ├── all-cli.nix
│ ├── default.nix │   │   │   ├── all-darwin.nix
│ └── hardware-configuration.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 ├── 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.

View file

@ -6,7 +6,7 @@
nixpkgs.url = "github:nixos/nixpkgs"; nixpkgs.url = "github:nixos/nixpkgs";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 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 = { nix-darwin = {
url = "github:lnl7/nix-darwin"; url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -35,44 +35,34 @@
}; # end inputs }; # end inputs
outputs = inputs@{ self, nixpkgs, nixpkgs-unstable, nix-darwin, home-manager, nix-homebrew, disko, genebean-omp-themes, ... }: let 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 # creates a macOS system config
darwinSystem = system: hostname: username: nix-darwin.lib.darwinSystem { darwinHostConfig = 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.7" ];
"python-2.7.18.7"
];
}; };
}; };
specialArgs = { inherit inputs username hostname; }; specialArgs = { inherit inputs username hostname; };
modules = [ modules = [
nix-homebrew.darwinModules.nix-homebrew nix-homebrew.darwinModules.nix-homebrew {
{
nix-homebrew = { nix-homebrew = {
# Install Homebrew under the default prefix enable = true; # Install Homebrew under the default prefix
enable = true; user = "${username}"; # User owning the Homebrew prefix
autoMigrate = true; # Automatically migrate existing Homebrew installations
# User owning the Homebrew prefix
user = "${username}";
# Automatically migrate existing Homebrew installations
autoMigrate = true;
}; };
} }
home-manager.darwinModules.home-manager home-manager.darwinModules.home-manager {
{
home-manager = { home-manager = {
extraSpecialArgs = { inherit genebean-omp-themes; };
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
users.${username}.imports = [ users.${username}.imports = [
./modules/home-manager/hosts/${hostname}/${username}.nix ./modules/home-manager/hosts/${hostname}/${username}.nix
]; ];
extraSpecialArgs = { inherit genebean-omp-themes; };
}; };
} }
@ -82,27 +72,24 @@
}; # end darwinSystem }; # end darwinSystem
# creates a nixos system config # creates a nixos system config
nixosSystem = system: hostname: username: nixpkgs.lib.nixosSystem { nixosHostConfig = system: hostname: username: nixpkgs.lib.nixosSystem {
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
config = { config = {
allowUnfree = true; allowUnfree = true;
permittedInsecurePackages = [ permittedInsecurePackages = [ "electron-21.4.4" ];
"electron-21.4.4" # Well, this sucks, hopefully a fixed version is available soon...
];
}; };
}; };
specialArgs = { inherit inputs username hostname; }; specialArgs = { inherit inputs username hostname; };
modules = [ modules = [
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager {
{
home-manager = { home-manager = {
extraSpecialArgs = { inherit genebean-omp-themes; };
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
users.${username}.imports = [ users.${username}.imports = [
./modules/home-manager/hosts/${hostname}/${username}.nix ./modules/home-manager/hosts/${hostname}/${username}.nix
]; ];
extraSpecialArgs = { inherit genebean-omp-themes; };
}; };
} }
@ -113,12 +100,12 @@
in { in {
darwinConfigurations = { darwinConfigurations = {
Blue-Rock = darwinSystem "x86_64-darwin" "Blue-Rock" "gene.liverman"; Blue-Rock = darwinHostConfig "x86_64-darwin" "Blue-Rock" "gene.liverman";
}; };
nixosConfigurations = { nixosConfigurations = {
nixnuc = nixosSystem "x86_64-linux" "nixnuc" "gene"; nixnuc = nixosHostConfig "x86_64-linux" "nixnuc" "gene";
rainbow-planet = nixosSystem "x86_64-linux" "rainbow-planet" "gene"; rainbow-planet = nixosHostConfig "x86_64-linux" "rainbow-planet" "gene";
}; };
}; };
} }