uhh it almost works

This commit is contained in:
Mira Kristipati 2025-05-23 01:35:12 -04:00
parent bcd9706454
commit ab4704240b
9 changed files with 318 additions and 131 deletions

View file

@ -1,17 +1,30 @@
# Consumes user.nix, configuration.nix # Consumes user.nix, configuration.nix
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, ...}:
{ {
config,
pkgs,
lib,
...
}: {
imports = [ imports = [
./configuration.nix ./configuration.nix
./user.nix ./user.nix
]; ];
calliope = { calliope = {
hostName = "marcille"; hostname = "marcille";
ipv4Address = "172.18.154.50"; ipv4Address = "172.18.154.50";
cec = "akristip"; cec = "akristip";
username = "mira"; name = "Mira Lastname";
# username = "mira";
shell = pkgs.xonsh; shell = pkgs.xonsh;
#password = ""; };
}
virtualisation.vmVariant = {
virtualisation = {
memorySize = 1024; # 16GiB
cores = 2; # 40 cores
# memorySize = 16384; # 16GiB
# cores = 40; # 40 cores
graphics = true;
};
};
} }

View file

@ -1,32 +1,32 @@
# Edit this configuration file to define what should be installed on # Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, lib, ... }:
{ {
# imports = config,
# [ # Include the results of the hardware scan. pkgs,
# ./user.nix lib,
# ]; ...
}: {
imports = [];
networking.nameservers = ["64.102.6.247"];
networking.search = ["cisco.com"];
networking.nameservers = [ "64.102.6.247" ];
networking.search = [ "cisco.com" ];
# Bootloader. # Bootloader.
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
nix.package = pkgs.lix; nix.package = pkgs.lix;
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = ["nix-command" "flakes"];
# TODO: migrate to calliope.nix
networking.hostName = "marcille"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary # Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/"; # networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Set your time zone. # Set your time zone.
time.timeZone = "America/New_York"; time.timeZone = "America/New_York";
@ -51,45 +51,44 @@
variant = ""; variant = "";
}; };
# Define a user account. Don't forget to set a password with passwd.
users.users.mira = {
isNormalUser = true;
description = "Mira";
extraGroups = [ "networkmanager" "wheel" ];
packages = with pkgs; [];
};
users.users.chris = {
isNormalUser = true;
description = "Chris";
extraGroups = [ "networkmanager" "wheel" ];
packages = with pkgs; [];
};
# Enable automatic login for the user.
services.getty.autologinUser = lib.mkDefault "mira";
# Allow unfree packages # Allow unfree packages
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. wget
# wget curl
lsd lsd
fd fd
ripgrep ripgrep
thefuck thefuck
nh nh
hyfetch disko
fastfetch hyfetch
uv fastfetch
edit uv
edit
networkmanager
gum
nushell
]; ];
programs.neovim = { programs = {
enable = true; xonsh.enable = true;
defaultEditor = true; zsh.enable = true;
fish.enable = true;
neovim = {
enable = true;
defaultEditor = true;
};
zoxide = {
enable = true;
enableZshIntegration = true;
enableFishIntegration = true;
enableXonshIntegration = true;
enableBashIntegration = true;
};
}; };
# Some programs need SUID wrappers, can be configured further or are # Some programs need SUID wrappers, can be configured further or are
# started in user sessions. # started in user sessions.
@ -103,7 +102,6 @@
enable = true; enable = true;
shortcut = "a"; shortcut = "a";
keyMode = "vi"; keyMode = "vi";
}; };
# TODO: copy git config here # TODO: copy git config here
@ -112,7 +110,6 @@
# TODO: set aliases (eg ls to lsd) # TODO: set aliases (eg ls to lsd)
# List services that you want to enable: # List services that you want to enable:
# Enable the OpenSSH daemon. # Enable the OpenSSH daemon.

57
disko-config.nix Normal file
View file

@ -0,0 +1,57 @@
# USAGE in your configuration.nix.
# Update devices to match your hardware.
# {
# imports = [ ./disko-config.nix ];
# disko.devices.disk.main.device = "/dev/sda";
# }
{
disko.devices = {
disk = {
main = {
type = "disk";
device = "/dev/vda"; # Format the first disk
content = {
type = "gpt";
partitions = {
ESP = {
priority = 1;
name = "ESP";
start = "1M";
end = "1G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = ["umask=0077"];
};
};
root = {
size = "100%";
content = {
type = "btrfs";
extraArgs = ["-f"]; # Override existing partition
subvolumes = {
"@rootfs" = {
mountpoint = "/";
};
"@home" = {
mountOptions = ["compress=zstd"];
mountpoint = "/home";
};
"@nix" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/nix";
};
};
};
};
};
};
};
};
};
}

21
flake.lock generated
View file

@ -1,5 +1,25 @@
{ {
"nodes": { "nodes": {
"disko": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1747742835,
"narHash": "sha256-kYL4GCwwznsypvsnA20oyvW8zB/Dvn6K5G/tgMjVMT4=",
"owner": "nix-community",
"repo": "disko",
"rev": "df522e787fdffc4f32ed3e1fca9ed0968a384d62",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "disko",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1747825515, "lastModified": 1747825515,
@ -18,6 +38,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"disko": "disko",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View file

@ -1,27 +1,34 @@
{ {
inputs = { inputs = {
# NOTE: Replace "nixos-23.11" with that which is in system.stateVersion of
# configuration.nix. You can also use latter versions if you wish to
# upgrade.
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
}; disko = {
outputs = inputs@{ self, nixpkgs, ... }: { url = "github:nix-community/disko";
# NOTE: 'nixos' is the default hostname set by the installer inputs.nixpkgs.follows = "nixpkgs";
nixosConfigurations.marcille = nixpkgs.lib.nixosSystem {
# NOTE: Change this to aarch64-linux if you are on ARM
system = "x86_64-linux";
modules = [
./configuration.nix
./hardware-configuration.nix
];
}; };
nixosConfigurations.live = nixpkgs.lib.nixosSystem { };
system = "x86_64-linux"; outputs = inputs @ {
modules = [ self,
(nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix") nixpkgs,
./configuration.nix ...
]; }: {
nixosConfigurations = {
calliope = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
inputs.disko.nixosModules.disko
./calliope.nix
./disko-config.nix
];
};
installer = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
targetSystem = inputs.self.nixosConfigurations.calliope;
};
modules = [
./installer.nix
];
};
}; };
}; };
} }

View file

@ -1,29 +1,33 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = [ ]; config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [];
boot.initrd.availableKernelModules = [ "ata_piix" "vmw_pvscsi" "ahci" "sd_mod" "sr_mod" ]; boot.initrd.availableKernelModules = ["ata_piix" "vmw_pvscsi" "ahci" "sd_mod" "sr_mod"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelModules = [ ]; boot.kernelModules = [];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/disk/by-uuid/2135c59d-9c2d-487c-9c4e-0f566fa9d316"; device = "/dev/disk/by-uuid/2135c59d-9c2d-487c-9c4e-0f566fa9d316";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=@" ]; options = ["subvol=@"];
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{ device = "/dev/disk/by-uuid/7E60-8E0B"; device = "/dev/disk/by-uuid/7E60-8E0B";
fsType = "vfat"; fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ]; options = ["fmask=0077" "dmask=0077"];
}; };
swapDevices = [ ]; swapDevices = [];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's
@ -32,20 +36,22 @@
networking.useDHCP = lib.mkDefault false; networking.useDHCP = lib.mkDefault false;
# networking.interfaces.ens33.useDHCP = lib.mkDefault true; # networking.interfaces.ens33.useDHCP = lib.mkDefault true;
networking.interfaces.ens33 = { networking.interfaces.ens33 = {
ipv4.addresses = [{ ipv4.addresses = [
address = "172.18.154.50"; {
prefixLength = 24; address = "172.18.154.50";
}]; prefixLength = 24;
}
];
}; };
# Enable networking # Enable networking
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
networking.defaultGateway = { networking.defaultGateway = {
address = "172.18.154.1"; address = "172.18.154.1";
interface = "ens33"; interface = "ens33";
}; };
networking.nameservers = [ "64.102.6.247" ]; networking.nameservers = ["64.102.6.247"];
networking.search = [ "cisco.com" ]; networking.search = ["cisco.com"];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
} }

58
installer.nix Normal file
View file

@ -0,0 +1,58 @@
{
config,
pkgs,
lib,
modulesPath,
targetSystem,
...
}: let
installer = pkgs.writeShellApplication {
name = "installer";
runtimeInputs = [];
text = ''
#!${pkgs.runtimeShell}
set -euo pipefail
echo "Formatting the disk..."
${pkgs.util-linux}/bin/blkid -o device > /tmp/devices
# DISKO_DEVICE_MAIN="$(${pkgs.gum}/bin/gum choose < /tmp/devices)"
DISKO_DEVICE_MAIN=/dev/vda
export DISKO_DEVICE_MAIN
echo "Selected device: $DISKO_DEVICE_MAIN"
${targetSystem.config.system.build.diskoScript}
export PATH=${lib.makeBinPath [
# hack for a progress bar
# https://nix.dev/manual/nix/2.18/command-ref/nix-build#opt-log-format
(pkgs.writeShellScriptBin "nix-env" ''
exec ${lib.getExe' config.nix.package "nix-env"} --log-format bar "$@"
'')
]}:$PATH
echo "Installing NixOS..."
${pkgs.nixos-install}/bin/nixos-install --no-channel-copy --no-root-password --option substituters "" --system ${targetSystem.config.system.build.toplevel}
'';
};
# This is a failsafe script that will run if the installer fails to start
installerFailsafe = pkgs.writeShellScript "failsafe" ''
${lib.getExe installer} || echo "ERROR: Installation failure!"
sleep 3600
'';
in {
imports = [
(modulesPath + "/installer/cd-dvd/iso-image.nix")
(modulesPath + "/profiles/all-hardware.nix")
];
boot.kernelParams = ["systemd.unit=getty.target"];
isoImage.squashfsCompression = "zstd -Xcompression-level 15"; # xz takes forever
# systemd service to start the installer on boot
system.stateVersion = "25.05";
systemd.services."getty@tty1" = {
overrideStrategy = "asDropin";
serviceConfig = {
ExecStart = ["" installerFailsafe];
Restart = "no";
StandardInput = "null";
};
};
}

10
justfile Normal file
View file

@ -0,0 +1,10 @@
build:
nix --extra-experimental-features nix-command --extra-experimental-features flakes build '.#nixosConfigurations.calliope.config.system.build.toplevel'
build-iso:
nix build -L '.#nixosConfigurations.installer.config.system.build.isoImage'
build-installer:
nixos-generate -f install-iso -c calliope.nix
#build-vm:
# nix --extra-experimental-features nix-command --extra-experimental-features flakes build '.#nixosConfigurations.calliopeISO.config.system.build.vm'

View file

@ -1,44 +1,62 @@
# User config definitions # User config definitions
{ config, pkgs, lib, ... }:
{ {
config,
options = { pkgs,
calliope = { lib,
hostname = lib.mkOption { ...
type = string; }:
default = "calliope"; with lib; let
cfg = config.calliope;
}; in {
ipv4Address = lib.mkOption { options.calliope = {
type = string; hostname = mkOption {
}; type = types.str;
# TODO: default = "calliope";
password = lib.mkOption {}; };
cec = lib.mkOption { ipv4Address = mkOption {
type = string; type = types.str;
username = lib.mkOption { };
type = string; name = mkOption {
# TODO: make this default to CEC type = types.str;
}; };
defaultShell = mkPackageOption pkgs "shell" { cec = mkOption {
default = [ "bash" ]; type = types.str;
}; };
username = mkOption {
type = types.str;
};
shell = mkOption {
default = pkgs.zsh;
type = types.package;
};
authorizedKeys = mkOption {
type = types.listOf types.singleLineStr;
default = [];
}; };
# TODO:
authorizedKeys = lib.mkOption {};
# TODO: # TODO:
sshIdentities = lib.mkOption {}; sshIdentities = mkOption {};
} };
config = { config = {
networking.hostName = options.calliope.hostname; calliope.username = lib.mkDefault cfg.cec;
# TODO: set the ipv4 address, and figure out how to set this without knowing interface name networking.hostName = cfg.hostname;
# TODO: set default gateway
# TODO: use CEC to set up git identity
# TODO: set default shell
# TODO: set authorized_keys
# TODO: set SSH Private keys
# Enable automatic login for the user.
services.getty.autologinUser = lib.mkDefault cfg.username;
# Define a user account. Don't forget to set a password with passwd.
users.users."${cfg.username}" = {
isNormalUser = true;
description = cfg.name;
initialPassword = "C!sc0!@#";
shell = cfg.shell;
extraGroups = ["networkmanager" "wheel"];
openssh.authorizedKeys.keys = cfg.authorizedKeys;
};
# TODO: set the ipv4 address, and figure out how to set this without knowing interface name
# TODO: set default gateway
# TODO: use CEC to set up git identity
# TODO: set SSH Private keys
}; };
} }