diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2025-10-18 13:12:33 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2025-10-18 13:12:33 +0530 |
| commit | 9ec569a1b34f17d32894d51614cff84d8952d868 (patch) | |
| tree | d5f3c27bd4654d90a69f77a569ef1d67b76861dc | |
| parent | 1638c8711b4a56347d0c1a4da4d949d71978915c (diff) | |
setup flake!!
now editing username is easier than ever! and no longer nix-channels.txt
with the long script installation
| -rw-r--r-- | flake.lock | 66 | ||||
| -rw-r--r-- | flake.nix | 44 | ||||
| -rw-r--r-- | hardware-configuration.nix | 39 | ||||
| -rw-r--r-- | home-manager/flake.lock | 48 | ||||
| -rw-r--r-- | home-manager/flake.nix | 22 | ||||
| -rw-r--r-- | home-manager/home.nix | 10 | ||||
| -rwxr-xr-x | install.sh | 40 | ||||
| -rw-r--r-- | nixos/configuration.nix | 16 | ||||
| -rw-r--r-- | nixos/home.nix | 15 | ||||
| -rw-r--r-- | nixos/nix-channel.txt | 3 | ||||
| -rw-r--r-- | nixos/nvidia.nix | 3 | ||||
| -rw-r--r-- | nixos/nvim.nix | 5 | ||||
| -rwxr-xr-x | sync.sh | 2 |
13 files changed, 177 insertions, 136 deletions
diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..36ed1db --- /dev/null +++ b/flake.lock @@ -0,0 +1,66 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1758463745, + "narHash": "sha256-uhzsV0Q0I9j2y/rfweWeGif5AWe0MGrgZ/3TjpDYdGA=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "3b955f5f0a942f9f60cdc9cacb7844335d0f21c3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-25.05", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1760580664, + "narHash": "sha256-/YdfibIrnqXAL8p5kqCU345mzpHoOtuVIkMiI2pF4Dc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "98ff3f9af2684f6136c24beef08f5e2033fc5389", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1760580664, + "narHash": "sha256-/YdfibIrnqXAL8p5kqCU345mzpHoOtuVIkMiI2pF4Dc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "98ff3f9af2684f6136c24beef08f5e2033fc5389", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d081fe6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + description = "System"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-25.05"; + home-manager = { + url = "github:nix-community/home-manager/release-25.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, ... }@inputs: + let + system = "x86_64-linux"; + username = "aargh"; + hostname = "pegasus"; + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + unstable = import nixpkgs-unstable { + inherit system; + config.allowUnfree = true; + }; + in { + nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { inherit inputs username hostname unstable; }; + + modules = [ + ./nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { inherit username unstable; }; + home-manager.backupFileExtension = "hm-backup"; + home-manager.users.${username} = import ./home-manager/home.nix; + } + ]; + }; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..9ac5330 --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,39 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/56ef1a1d-db2f-45e9-b66a-f70f673596bf"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/4DAE-E6E8"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = [ ]; + + # 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 + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/home-manager/flake.lock b/home-manager/flake.lock deleted file mode 100644 index db647bc..0000000 --- a/home-manager/flake.lock +++ /dev/null @@ -1,48 +0,0 @@ -{ - "nodes": { - "home-manager": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1751411489, - "narHash": "sha256-x+AJyQ5+4EPDU3NnQ1OPP/KuoG0C6UrbgptEW6PSLQ8=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "e96a8a325cf23538a7f58b9335b4c4c0b393bacf", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "home-manager", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1751271578, - "narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "home-manager": "home-manager", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/home-manager/flake.nix b/home-manager/flake.nix deleted file mode 100644 index dfad9c8..0000000 --- a/home-manager/flake.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ - description = "Home Manager configuration"; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - outputs = - { nixpkgs, home-manager, ... }: - let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - in - { - homeConfigurations."aargh" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [ ./home.nix ]; - }; - }; -} diff --git a/home-manager/home.nix b/home-manager/home.nix index 5df8918..aec1491 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -1,8 +1,8 @@ -{ config, pkgs, ... }: +{ config, pkgs, username, ... }: { - home.username = "aargh"; - home.homeDirectory = "/home/aargh"; - home.stateVersion = "24.11"; + home.username = username; + home.homeDirectory = "/home/${username}"; + home.stateVersion = "25.05"; home.packages = with pkgs; [ devenv # # Adds the 'hello' command to your environment. It prints a friendly @@ -41,7 +41,7 @@ # ''; }; home.sessionVariables = { - # EDITOR = "emacs"; + EDITOR = "nvim"; }; programs.home-manager.enable = true; } @@ -2,42 +2,14 @@ echo "Inserting files..." mkdir -p ~/.config -sudo cp -r hypr foot nvim tmux waybar wofi yazi home-manager starship.toml ~/.config +sudo cp -r hypr foot nvim tmux waybar wofi yazi starship.toml ~/.config sudo cp -r Wallpapers ~/Pictures +# Although we are sending the configs to /etc/nixos, we aren't actually using them with the flake setup +# Consider the operation purely for vanity sudo cp -r nixos /etc -sudo nixos-generate-config +sudo cp -r hardware-configuration.nix /etc/nixos -CHANNEL_FILE="nixos/nix-channel.txt" -if [[ ! -f "$CHANNEL_FILE" ]]; then - echo "Error: Channel file not found at $CHANNEL_FILE" - exit 1 -fi -current_channels=$(sudo nix-channel --list) - -# Read and process each channel from file -while IFS= read -r line || [[ -n "$line" ]]; do - # Skip empty lines and comments - [[ -z "$line" ]] || [[ "$line" =~ ^[[:space:]]*# ]] && continue - - # Parse channel name and URL (format: "name url") - channel_name=$(echo "$line" | awk '{print $1}') - channel_url=$(echo "$line" | awk '{print $2}') - - # Check if channel already exists - if echo "$current_channels" | grep -q "^$channel_name "; then - echo "✓ Channel '$channel_name' already exists" - else - echo "Adding channel '$channel_name' from $channel_url" - sudo nix-channel --add "$channel_url" "$channel_name" - fi -done < "$CHANNEL_FILE" - -# Update channels after adding new ones -echo "Updating channels..." -sudo nix-channel --update - -echo "Switching..." -sudo nixos-rebuild switch -home-manager switch +sudo nixos-generate-config --show-hardware-config > hardware-configuration.nix +sudo nixos-rebuild switch --flake .#pegasus diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 51274f9..d3a996a 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -1,8 +1,8 @@ -{ config, pkgs, ... }: +{ config, pkgs, username, hostname, ... }: { imports = [ - ./hardware-configuration.nix + ../hardware-configuration.nix ./cachix.nix ./boot.nix ./services.nix @@ -14,20 +14,24 @@ ./languages ./apps.nix ./tmux.nix - <home-manager/nixos> ]; nix.settings = { cores = 6; max-jobs = 2; + experimental-features = "nix-command flakes"; + trusted-users = [ "root" username ]; + }; + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; }; - networking.hostName = "pegasus"; + networking.hostName = hostname; networking.networkmanager.enable = true; nixpkgs.config.allowUnfree = true; - nix.settings.experimental-features = "nix-command flakes"; - nix.settings.trusted-users = [ "root" "aargh" ]; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/nixos/home.nix b/nixos/home.nix index 0a5fdd4..054d002 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -1,8 +1,8 @@ -{ config, pkgs, ... }: +{ config, pkgs, username, ... }: { - users.users.aargh = { + users.users.${username} = { isNormalUser = true; - description = "Aargh"; + description = "User"; extraGroups = [ "networkmanager" "wheel" "kvm" "adbusers" ]; packages = with pkgs; []; shell = pkgs.fish; @@ -10,15 +10,6 @@ programs.adb.enable = true; programs.fish.enable = true; programs.firefox.enable = true; - home-manager.users.aargh = { pkgs, ... }: { - home.stateVersion = "25.05"; - }; - home-manager.backupFileExtension = "hm-backup"; - nix.gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 10d"; - }; environment.systemPackages = with pkgs; [ home-manager ]; diff --git a/nixos/nix-channel.txt b/nixos/nix-channel.txt deleted file mode 100644 index 133e61f..0000000 --- a/nixos/nix-channel.txt +++ /dev/null @@ -1,3 +0,0 @@ -home-manager https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz -nix-ld https://github.com/Mic92/nix-ld/archive/main.tar.gz -nixos-unstable https://nixos.org/channels/nixos-unstable diff --git a/nixos/nvidia.nix b/nixos/nvidia.nix index 14a4f2c..63db5b2 100644 --- a/nixos/nvidia.nix +++ b/nixos/nvidia.nix @@ -1,6 +1,5 @@ { config, pkgs, ... }: -let unstable = import <nixos-unstable> { config.allowUnfree = true; }; -in { +{ hardware.graphics.enable = true; hardware.nvidia = { modesetting.enable = true; diff --git a/nixos/nvim.nix b/nixos/nvim.nix index 1a38a86..ffcbc26 100644 --- a/nixos/nvim.nix +++ b/nixos/nvim.nix @@ -1,6 +1,5 @@ -{ config, pkgs, ... }: -let unstable = import <nixos-unstable> { config.allowUnfree = true; }; -in { +{ config, pkgs, unstable, ... }: +{ environment.systemPackages = with pkgs; [ unstable.neovim @@ -1,6 +1,6 @@ #!/usr/bin/env bash -sudo rm -rf hypr foot nixos nvim tmux waybar wofi yazi home-manager Wallpapers starship.toml +sudo rm -rf hypr foot nixos nvim tmux waybar wofi yazi Wallpapers starship.toml sudo cp -r ~/.config/hypr . sudo cp -r ~/.config/foot . sudo cp -r ~/.config/nvim . |
