1
0
Fork 0

Additional cleanup - now getting at flake.nix

This commit is contained in:
Aires 2024-05-03 17:32:27 -04:00
parent 13efb4de95
commit 4bc4adc5be
14 changed files with 55 additions and 106 deletions

View file

@ -17,21 +17,30 @@ Initialize the submodule with:
git submodule update --init --recursive
```
### Applying the configuration
### Installing and upgrading
To apply the config for the first time (e.g. on a fresh install), run this command, replacing `Shura` with the name of the host:
To apply the config for the first time (e.g. on a fresh install), run these commands, replacing `Shura` with the name of the host:
```sh
nix flake update
sudo nixos-rebuild switch --flake .#Shura
```
```
For subsequent builds, you can omit the hostname, and/or use nh:
`nix flake update` updates the `flake.lock` file, which pins repositories to specific versions. Nix will then pull down any derivations it needs to meet the version.
> [!NOTE]
> This config installs a [Nix wrapper called nh](https://github.com/viperML/nh). Basic install/upgrade commands can be run using `nh`, but more advanced stuff should use `nixos-rebuild`.
For subsequent builds, you can omit the hostname:
```sh
nh os switch
```
```sh
or
```sh
nix flake update
sudo nixos-rebuild switch --flake .
```
@ -48,15 +57,7 @@ You can build any Nix or NixOS expression on a remote system before copying it o
nixos-rebuild boot --flake . --build-host haven
```
### Upgrading
This config installs a [Nix wrapper called nh](https://github.com/viperML/nh). To use it, run:
```sh
nh os boot --update
```
You can replace `boot` with `switch`, or add `--ask` to confirm before installing.
You can also define build targets in a Nix config file. See Dimaga for an example.
### Testing

View file

@ -1,5 +1,5 @@
# Based on the Auxolotl template: https://github.com/auxolotl/templates
# For info on Flakes, see: https://nixos-and-flakes.thiscute.world/nixos-with-flakes/nixos-with-flakes-enabled
{
description = "Aires' system Flake";
@ -27,19 +27,18 @@
outputs = inputs@{ self, nixpkgs, lanzaboote, nix-flatpak, home-manager, nixos-hardware, ... }:
let
inherit (self) outputs;
inherit (nixpkgs) lib;
systems = [ "x86_64-linux" "aarch64-linux" ];
forEachSystem = f: lib.genAttrs systems (sys: f pkgsFor.${sys});
pkgsFor = lib.genAttrs systems (system: import nixpkgs {
inherit system;
config.allowUnfree = true;
});
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
] (system: function nixpkgs.legacyPackages.${system});
config.allowUnfree = true;
# Define shared modules and imports
defaultModules = {
base = [
{ _module.args = { inherit inputs; }; }
./hosts/default.nix
lanzaboote.nixosModules.lanzaboote
nix-flatpak.nixosModules.nix-flatpak
home-manager.nixosModules.home-manager {
@ -57,8 +56,9 @@
];
};
in {
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
nixosConfigurations = {
# Microsoft Surface Laptop Go
Dimaga = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = defaultModules.base ++ [
@ -67,7 +67,6 @@
];
};
# Home server
Haven = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = defaultModules.base ++ [
@ -76,7 +75,6 @@
];
};
# Microsoft Surface Pro 9
Khanda = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = defaultModules.base ++ [
@ -85,7 +83,6 @@
];
};
# Raspberry Pi
Pihole = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = defaultModules.base ++ [
@ -94,7 +91,6 @@
];
};
# Lenovo Legion Slim 7 Gen 7 AMD
Shura = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = defaultModules.base ++ [

View file

@ -1,12 +1,5 @@
{ pkgs, ... }:
# Settings specific to Dimaga
{
imports = [
./hardware-configuration.nix
../common
];
{ pkgs, ... }: {
imports = [ ./hardware-configuration.nix ];
system.stateVersion = "24.05";
@ -17,7 +10,7 @@
kdeconnect.enable = true;
media.enable = true;
office.enable = true;
pandoc.enable = true;
writing.enable = true;
};
ui = {
flatpak.enable = true;

View file

@ -1,7 +1,5 @@
# Surface Laptop Go
{ config, lib, pkgs, modulesPath, ... }:
{
# Surface Laptop Go 1st gen
{ config, lib, pkgs, modulesPath, ... }: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];

View file

@ -1,15 +1,9 @@
{ pkgs, home-manager, lib, config, ... }:
# Settings specific to Haven
let
start-haven = pkgs.writeShellScriptBin "start-haven" (builtins.readFile ./start-haven.sh);
in
{
imports = [
./hardware-configuration.nix
../common
];
imports = [ ./hardware-configuration.nix ];
system.stateVersion = "24.05";
system.autoUpgrade.enable = lib.mkForce false;

View file

@ -1,6 +1,5 @@
{ config, lib, pkgs, modulesPath, ... }:
{
# Minisforum UM340
{ config, lib, pkgs, modulesPath, ... }: {
imports =
[ (modulesPath + "/installer/scan/not-detected.nix") ];

View file

@ -1,12 +1,5 @@
{ pkgs, lib, ... }:
# Settings specific to Dimaga
{
imports = [
./hardware-configuration.nix
../common
];
{ pkgs, lib, ... }: {
imports = [ ./hardware-configuration.nix ];
system.stateVersion = "24.05";
system.autoUpgrade.enable = lib.mkForce false;

View file

@ -1,7 +1,5 @@
# Surface Pro 9
{ config, lib, pkgs, modulesPath, ... }:
{
{ config, lib, pkgs, modulesPath, ... }: {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = {

View file

@ -1,12 +1,5 @@
{ pkgs, lib, ... }:
# Settings specific to Raspberry Pi 4b
{
imports = [
./hardware-configuration.nix
../common
];
{ pkgs, lib, ... }: {
imports = [ ./hardware-configuration.nix ];
system.stateVersion = "24.05";

View file

@ -1,4 +1,4 @@
# Raspberry Pi 4
# Raspberry Pi 4B
# See https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_4
{ config, lib, pkgs, modulesPath, nixos-hardware, ... }:

View file

@ -1,7 +1,4 @@
{ config, pkgs, lib, ... }:
# Configuration options unique to Shura
let
# Copy bluetooth device configs
shure-aonic-bluetooth = pkgs.writeText "info" (builtins.readFile ./bluetooth/shure-aonic-bluetooth-params);
@ -13,10 +10,7 @@ let
monitorsConfig = pkgs.writeText "gdm_monitors.xml" monitorsXmlContent;
in
{
imports = [
./hardware-configuration.nix
../common
];
imports = [ ./hardware-configuration.nix ];
system.stateVersion = "24.05";

View file

@ -1,6 +1,5 @@
# Lenovo Legion S7 16ARHA7 configuration
{ config, lib, pkgs, modulesPath, ... }:
{
# Lenovo Legion Slim 7 Gen 7 AMD (16ARHA7)
{ config, lib, pkgs, modulesPath, ... }: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];

View file

@ -1,15 +0,0 @@
{ lib, pkgs, ... }:
let
# Fetch secrets
# IMPORTANT: Make sure this repo exists on the filesystem first!
nix-secrets = builtins.fetchGit {
url = "/home/aires/Development/nix-configuration/nix-secrets";
ref = "main";
rev = "55fc814d477d956ab885e157f24c2d43f433dc7a";
};
in{
imports = [
../../modules
"${nix-secrets}/default.nix"
];
}

View file

@ -1,9 +1,15 @@
{ ... }: {
{ lib, pkgs, ... }:
let
# Fetch secrets
# IMPORTANT: Make sure this repo exists on the filesystem first!
nix-secrets = builtins.fetchGit {
url = "/home/aires/Development/nix-configuration/nix-secrets";
ref = "main";
rev = "55fc814d477d956ab885e157f24c2d43f433dc7a";
};
in{
imports = [
./Dimaga
./Haven
./Khanda
./Pihole
./Shura
"${nix-secrets}/default.nix"
../modules
];
}
}