Skip to content

Commit

Permalink
feat(hosts): add iso build
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelreyrol committed Apr 7, 2024
1 parent 4cd5454 commit eb34097
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ pi0-deploy:

apu-deploy:
nixos-rebuild switch -j auto --flake .#apu --target-host [email protected] --use-remote-sudo -v

iso:
nix build .#nixosConfigurations.iso.config.system.build.isoImage
6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
host = "thinkpad";
user = "gael";
}
{
system = "x86_64-linux";
host = "iso";
user = "nixos";
iso = true;
}
];

packages = forSystems ({ pkgs, system }: pkgs.myPkgs);
Expand Down
15 changes: 15 additions & 0 deletions hosts/iso/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ lib, pkgs, ... }:

{
imports = [
./hardware-configuration.nix
];

console.keyMap = "fr";

environment.systemPackages = [
pkgs.fwupd
pkgs.lshw
pkgs.tmux
];
}
22 changes: 22 additions & 0 deletions hosts/iso/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ lib, modulesPath, pkgs, ... }:

{
imports = [
(modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix")
(modulesPath + "/installer/cd-dvd/channel.nix")
];

nixpkgs.config.allowUnfree = true;

boot = {
kernelPackages = pkgs.unstable.linuxKernel.packages.linux_6_8;

# Needed for https://github.com/NixOS/nixpkgs/issues/58959
supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
};

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

hardware.enableAllFirmware = true;
hardware.enableRedistributableFirmware = true;
}
21 changes: 11 additions & 10 deletions lib/os/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let
inherit (inputs) self nixpkgs sops-nix nur home-manager udev-nix;
in
rec {
mkNixosSystem = { system, host, user, ... }: nixpkgs.lib.nixosSystem {
mkNixosSystem = { system, host, user, iso ? false, ... }: nixpkgs.lib.nixosSystem {
inherit system;

specialArgs = {
Expand Down Expand Up @@ -47,29 +47,30 @@ rec {
);
})

../../mixins/nix
../../mixins
../../hosts/${host}/configuration.nix
../../users/${user}/configuration.nix

sops-nix.nixosModules.sops

home-manager.nixosModules.home-manager
nur.nixosModules.nur
{
({
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${user} = builtins.import ../../users/${user}/home.nix;
sharedModules = [
sharedModules = [] ++ (nixpkgs.lib.optionals (!iso) [
sops-nix.homeManagerModules.sops
];
]);
};
} // (nixpkgs.lib.optionalAttrs (!iso) {
sops = {
defaultSopsFile = ../../secrets/default.yaml;
};
}
];
}))
] ++ (nixpkgs.lib.optionals (!iso) [
../../mixins/nix
../../mixins
sops-nix.nixosModules.sops
]);
};

mkNixosSystems = systems: builtins.listToAttrs (
Expand Down
1 change: 1 addition & 0 deletions mixins/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"gael"
"lab"
"router"
"nixos"
];
secret-key-files = "/var/nix/cache-priv-key.pem";
trusted-public-keys = [
Expand Down
16 changes: 16 additions & 0 deletions users/nixos/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ config, pkgs, ... }:

{
users.users.nixos = {
isNormalUser = true;
description = "NixOS";
extraGroups = [ "wheel" "networkmanager" ];
shell = pkgs.bash;
password = "nixos";

openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG8l0V91as58J0G8USUuxqnYZH0InHK317UnTurWgkAK gael@tower"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEDaOQVs/WLWCIahRTfAmolgLV2jWL6EasDM6O++rq1M gael@thinkpad"
];
};
}
33 changes: 33 additions & 0 deletions users/nixos/home.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ config, pkgs, ... }:

{
imports = [
../../mixins/activation/home-report-changes.nix
];

home = {
stateVersion = "23.11";
sessionVariables = {
EDITOR = "vim";
};
};

programs = {
home-manager.enable = true;

vim.enable = true;
jq.enable = true;

fzf = {
enable = true;
tmux.enableShellIntegration = true;
};

tmux = {
enable = true;
plugins = with pkgs; [
tmuxPlugins.tmux-fzf
];
};
};
}

0 comments on commit eb34097

Please sign in to comment.