restructure flake (#14)

* initial commit

* simplify output structure

* don't pull wallpaper from flake, use fetchGit

* swap nixvim for neovim

* fetch wallpaper correctly

* move nixvim to aly home config
This commit is contained in:
Aly Raffauf 2024-07-09 19:17:53 -04:00 committed by GitHub
parent 17c234ac67
commit 945fbdcc39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 157 additions and 165 deletions

View file

@ -1,4 +1,4 @@
inputs: {
self: {
config,
lib,
pkgs,

View file

@ -508,7 +508,7 @@
"type": "github"
}
},
"nixpkgsUnstable": {
"nixpkgs-unstable": {
"locked": {
"lastModified": 1720418205,
"narHash": "sha256-cPJoFPXU44GlhWg4pUk9oUPqurPlCFZ11ZQPk21GTPU=",
@ -612,11 +612,10 @@
"iio-hyprland": "iio-hyprland",
"nixhw": "nixhw",
"nixpkgs": "nixpkgs_2",
"nixpkgsUnstable": "nixpkgsUnstable",
"nixpkgs-unstable": "nixpkgs-unstable",
"nixvim": "nixvim",
"nur": "nur",
"raffauflabs": "raffauflabs",
"wallpapers": "wallpapers"
"raffauflabs": "raffauflabs"
}
},
"systems": {
@ -700,26 +699,6 @@
"type": "github"
}
},
"wallpapers": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1720441472,
"narHash": "sha256-DmNtKWSUUZMMx/iVG+uBaDVZVYtTuqBDLlXuszkyU98=",
"owner": "alyraffauf",
"repo": "wallpapers",
"rev": "450b10fe4c206fe28a5e9dcc9e00d4f6e518815b",
"type": "github"
},
"original": {
"owner": "alyraffauf",
"repo": "wallpapers",
"type": "github"
}
},
"xdph": {
"inputs": {
"hyprland-protocols": "hyprland-protocols",

132
flake.nix
View file

@ -3,35 +3,57 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgsUnstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
agenix = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:ryantm/agenix";
};
disko = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:nix-community/disko";
};
home-manager = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:nix-community/home-manager/release-24.05";
};
agenix.url = "github:ryantm/agenix";
disko.url = "github:nix-community/disko";
home-manager.url = "github:nix-community/home-manager/release-24.05";
hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1";
iio-hyprland.url = "github:JeanSchoeller/iio-hyprland";
nixhw.url = "github:alyraffauf/nixhw";
nixvim.url = "github:nix-community/nixvim/nixos-24.05";
nur.url = "github:nix-community/NUR";
raffauflabs.url = "github:alyraffauf/raffauflabs";
wallpapers.url = "github:alyraffauf/wallpapers";
agenix.inputs.nixpkgs.follows = "nixpkgs";
disko.inputs.nixpkgs.follows = "nixpkgs";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
iio-hyprland.inputs.nixpkgs.follows = "nixpkgs";
nixhw.inputs.nixpkgs.follows = "nixpkgs";
nixvim.inputs.nixpkgs.follows = "nixpkgs";
raffauflabs.inputs.nixpkgs.follows = "nixpkgs";
wallpapers.inputs.nixpkgs.follows = "nixpkgs";
iio-hyprland = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:JeanSchoeller/iio-hyprland";
};
nixhw = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:alyraffauf/nixhw";
};
nixvim = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:nix-community/nixvim/nixos-24.05";
};
nur.url = "github:nix-community/NUR";
raffauflabs = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:alyraffauf/raffauflabs";
};
};
nixConfig = {
accept-flake-config = true;
extra-substituters = [
"https://alyraffauf.cachix.org"
"https://hyprland.cachix.org"
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"alyraffauf.cachix.org-1:GQVrRGfjTtkPGS8M6y7Ik0z4zLt77O0N25ynv2gWzDM="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
@ -39,20 +61,20 @@
];
};
outputs = inputs @ {self, ...}: let
forDefaultSystems = inputs.nixpkgs.lib.genAttrs [
outputs = {self, ...}: let
forDefaultSystems = self.inputs.nixpkgs.lib.genAttrs [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
forLinuxSystems = inputs.nixpkgs.lib.genAttrs [
forLinuxSystems = self.inputs.nixpkgs.lib.genAttrs [
"aarch64-linux"
"x86_64-linux"
];
forAllHosts = inputs.nixpkgs.lib.genAttrs [
forAllHosts = self.inputs.nixpkgs.lib.genAttrs [
"fallarbor"
"lavaridge"
"mandarin"
@ -61,74 +83,44 @@
"rustboro"
];
in {
formatter = forDefaultSystems (system: inputs.nixpkgs.legacyPackages.${system}.alejandra);
formatter = forDefaultSystems (system: self.inputs.nixpkgs.legacyPackages.${system}.alejandra);
packages = forLinuxSystems (system: {
default = inputs.nixpkgs.legacyPackages."${system}".writeShellScriptBin "clean-install" ''
# Check if an argument is provided
if [ $# -eq 0 ]; then
echo "Error: Please provide a valid hostname as an argument."
exit 1
fi
HOST=$1
FLAKE=github:alyraffauf/nixcfg#$HOST
echo "Warning: Running this script will wipe the currently installed system."
read -p "Do you want to continue? (y/n): " answer
if [ "$answer" != "y" ]; then
echo "Aborted."
exit 0
fi
sudo nix --experimental-features "nix-command flakes" run \
github:nix-community/disko -- --mode disko --flake $FLAKE
# Install NixOS with the updated flake input and root settings
sudo nixos-install --no-root-password --root /mnt --flake $FLAKE
'';
default = self.inputs.nixpkgs.legacyPackages."${system}".writeShellApplication {
name = "clean-install";
text = ./flake/clean-install.sh;
};
});
homeManagerModules = {
default = import ./homeManagerModules inputs self;
aly = import ./homes/aly inputs self;
dustin = import ./homes/dustin inputs self;
morgan = import ./homes/morgan inputs self;
default = import ./homeManagerModules self;
aly = import ./homes/aly self;
dustin = import ./homes/dustin self;
morgan = import ./homes/morgan self;
};
nixosModules = {
base = import ./baseModules inputs;
nixos = import ./nixosModules inputs;
users = import ./userModules inputs;
base = import ./baseModules self;
nixos = import ./nixosModules self;
users = import ./userModules self;
};
nixosConfigurations = forAllHosts (
host:
inputs.nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs self;};
self.inputs.nixpkgs.lib.nixosSystem {
specialArgs = {inherit self;};
modules = [
./hosts/${host}
inputs.agenix.nixosModules.default
inputs.disko.nixosModules.disko
inputs.home-manager.nixosModules.home-manager
inputs.raffauflabs.nixosModules.raffauflabs
self.inputs.agenix.nixosModules.default
self.inputs.disko.nixosModules.disko
self.inputs.home-manager.nixosModules.home-manager
self.nixosModules.base
self.nixosModules.nixos
self.nixosModules.users
{
home-manager = {
backupFileExtension = "backup";
extraSpecialArgs = {inherit inputs self;};
sharedModules = [
inputs.agenix.homeManagerModules.default
inputs.nixvim.homeManagerModules.nixvim
inputs.nur.hmModules.nur
self.homeManagerModules.default
];
extraSpecialArgs = {inherit self;};
useGlobalPkgs = true;
useUserPackages = true;
};

22
flake/clean-install.sh Executable file
View file

@ -0,0 +1,22 @@
# Check if an argument is provided
if [ $# -eq 0 ]; then
echo "Error: Please provide a valid hostname as an argument."
exit 1
fi
HOST=$1
FLAKE=github:alyraffauf/nixcfg#$HOST
echo "Warning: Running this script will wipe the currently installed system."
read -p "Do you want to continue? (y/n): " answer
if [ "$answer" != "y" ]; then
echo "Aborted."
exit 0
fi
sudo nix --experimental-features "nix-command flakes" run \
github:nix-community/disko -- --mode disko --flake $FLAKE
# Install NixOS with the updated flake input and root settings
sudo nixos-install --no-root-password --root /mnt --flake $FLAKE

View file

@ -16,7 +16,6 @@
./librewolf
./mako
./nemo
./neovim
./swaylock
./thunar
./tmux

View file

@ -1,21 +0,0 @@
{
pkgs,
lib,
config,
...
}: {
config = lib.mkIf config.ar.home.apps.neovim.enable {
programs.nixvim = {
enable = true;
colorschemes.ayu.enable = true;
plugins = {
lightline.enable = true;
markdown-preview.enable = true;
neo-tree.enable = true;
neogit.enable = true;
nix.enable = true;
};
};
};
}

View file

@ -1,4 +1,4 @@
inputs: self: {
self: {
config,
pkgs,
lib,

View file

@ -48,6 +48,12 @@
) "file://${config.home.homeDirectory}/sync";
xdg = {
dataFile."backgrounds".source = builtins.fetchGit {
url = "https://github.com/alyraffauf/wallpapers.git";
rev = "7603a8aa36b0d8d76bd9fd80d19e8b601e4839aa";
ref = "master";
};
userDirs = {
enable = true;
createDirectories = true;

View file

@ -1,8 +1,8 @@
{
config,
inputs,
lib,
pkgs,
self,
...
}: {
config = let
@ -45,7 +45,7 @@
pkgs.writers.writeRuby "hyprland-randomWallpaper" {} ''
require 'fileutils'
directory = "${inputs.wallpapers.packages.${pkgs.system}.default}/share/backgrounds"
directory = "${config.xdg.dataHome}/backgrounds/"
hyprctl = "${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"}"
old_pids = []

View file

@ -1,15 +1,15 @@
{
config,
inputs,
lib,
pkgs,
self,
...
}: let
sway-randomWallpaper = pkgs.writeShellScriptBin "sway-randomWallpaper" ''
kill `pidof swaybg`
OLD_PIDS=()
directory=${inputs.wallpapers.packages.${pkgs.system}.default}/share/backgrounds
directory=${config.xdg.dataHome}/backgrounds
if [ -d "$directory" ]; then
while true; do

View file

@ -1,9 +1,9 @@
{
config,
inputs,
lib,
osConfig,
pkgs,
self,
...
}: let
cfg = config.ar.home;
@ -102,7 +102,7 @@ in {
terminalEditor = lib.mkOption {
description = "Default terminal editor package.";
default = config.programs.nixvim.package;
default = config.programs.neovim.package;
type = lib.types.package;
};
@ -284,7 +284,7 @@ in {
wallpaper = lib.mkOption {
description = "Default wallpaper.";
default = "${inputs.wallpapers.packages.${pkgs.system}.defaults}/share/backgrounds/jr-korpa-9XngoIpxcEo-unsplash.jpg";
default = "${config.xdg.dataHome}/backgrounds/jr-korpa-9XngoIpxcEo-unsplash.jpg";
type = lib.types.str;
};
};

View file

@ -1,4 +1,4 @@
inputs: self: {
self: {
config,
lib,
pkgs,
@ -8,6 +8,10 @@ inputs: self: {
./firefox
./mail
./windowManagers
self.homeManagerModules.default
self.inputs.agenix.homeManagerModules.default
self.inputs.nixvim.homeManagerModules.nixvim
self.inputs.nur.hmModules.nur
];
home = {
@ -36,14 +40,27 @@ inputs: self: {
};
programs = {
home-manager.enable = true;
git = {
enable = true;
lfs.enable = true;
userName = "Aly Raffauf";
userEmail = "aly@raffauflabs.com";
};
home-manager.enable = true;
nixvim = {
enable = true;
colorschemes.ayu.enable = true;
plugins = {
lightline.enable = true;
markdown-preview.enable = true;
neo-tree.enable = true;
neogit.enable = true;
nix.enable = true;
};
};
};
systemd.user.startServices = "legacy"; # Needed for auto-mounting agenix secrets.
@ -66,7 +83,7 @@ inputs: self: {
theme = {
enable = true;
wallpaper = "${inputs.wallpapers.packages.${pkgs.system}.default}/share/backgrounds/wallhaven-3led2d.jpg";
wallpaper = "${config.xdg.dataHome}/backgrounds/wallhaven-3led2d.jpg";
};
};
}

View file

@ -1,9 +1,11 @@
inputs: self: {
self: {
config,
lib,
pkgs,
...
}: {
imports = [self.homeManagerModules.default];
home = {
username = "dustin";
homeDirectory = "/home/dustin";
@ -41,7 +43,7 @@ inputs: self: {
theme = {
enable = true;
wallpaper = "${inputs.wallpapers.packages.${pkgs.system}.default}/share/backgrounds/jr-korpa-9XngoIpxcEo-unsplash.jpg";
wallpaper = "${config.xdg.dataHome}/backgrounds/jr-korpa-9XngoIpxcEo-unsplash.jpg";
};
};
}

View file

@ -1,9 +1,11 @@
inputs: self: {
self: {
config,
lib,
pkgs,
...
}: {
imports = [self.homeManagerModules.default];
home = {
username = "morgan";
homeDirectory = "/home/morgan";
@ -38,7 +40,7 @@ inputs: self: {
theme = {
enable = true;
wallpaper = "${inputs.wallpapers.packages.${pkgs.system}.default}/share//backgrounds/jr-korpa-9XngoIpxcEo-unsplash.jpg";
wallpaper = "${config.xdg.dataHome}/backgrounds/jr-korpa-9XngoIpxcEo-unsplash.jpg";
};
};
}

View file

@ -1,8 +1,8 @@
{
config,
inputs,
lib,
pkgs,
self,
...
}: {
age.secrets = {
@ -12,7 +12,7 @@
environment = {
systemPackages = with pkgs; [
inputs.agenix.packages.${pkgs.system}.default
self.inputs.agenix.packages.${pkgs.system}.default
inxi
];
@ -103,8 +103,8 @@
overlays = [
(final: prev: {
hyprland = inputs.hyprland.packages.${pkgs.system}.hyprland;
xdg-desktop-portal-hyprland = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland;
hyprland = self.inputs.hyprland.packages.${pkgs.system}.hyprland;
xdg-desktop-portal-hyprland = self.inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland;
})
];
};

View file

@ -1,16 +1,16 @@
# Framework 13 with 11th gen Intel Core i5, 16GB RAM, 512GB SSD.
{
config,
inputs,
lib,
pkgs,
self,
...
}: {
imports = [
../common.nix
./disko.nix
./home.nix
inputs.nixhw.nixosModules.framework-13-intel-11th
self.inputs.nixhw.nixosModules.framework-13-intel-11th
];
age.secrets = {

View file

@ -1,6 +1,5 @@
{
config,
inputs,
lib,
pkgs,
...

View file

@ -1,7 +1,6 @@
# Framework Laptop 13 with AMD Ryzen 7640U, 32GB RAM, 1TB SSD.
{
config,
inputs,
lib,
pkgs,
self,
@ -11,7 +10,7 @@
../common.nix
./disko.nix
./home.nix
inputs.nixhw.nixosModules.framework-13-amd-7000
self.inputs.nixhw.nixosModules.framework-13-amd-7000
];
age.secrets = {

View file

@ -1,6 +1,5 @@
{
config,
inputs,
lib,
pkgs,
...

View file

@ -1,19 +1,19 @@
# Custom desktop with AMD Ryzen 5 5600x, 32GB RAM, AMD Rx 7800 XT, and 1TB SSD + 2TB SSD.
{
config,
inputs,
lib,
pkgs,
self,
...
}: {
imports = [
../common.nix
./disko.nix
./home.nix
inputs.nixhw.nixosModules.common-amd-cpu
inputs.nixhw.nixosModules.common-amd-gpu
inputs.nixhw.nixosModules.common-bluetooth
inputs.nixhw.nixosModules.common-ssd
self.inputs.nixhw.nixosModules.common-amd-cpu
self.inputs.nixhw.nixosModules.common-amd-gpu
self.inputs.nixhw.nixosModules.common-bluetooth
self.inputs.nixhw.nixosModules.common-ssd
];
boot = {

View file

@ -1,6 +1,5 @@
{
config,
inputs,
lib,
pkgs,
...

View file

@ -1,9 +1,9 @@
# Custom desktop with AMD Ryzen 5 2600, 16GB RAM, AMD Rx 6700, and 1TB SSD + 2TB HDD.
{
config,
inputs,
lib,
pkgs,
self,
...
}: let
archiveDirectory = "/mnt/Archive";
@ -14,10 +14,11 @@ in {
../common.nix
./filesystems.nix
./home.nix
inputs.nixhw.nixosModules.common-amd-cpu
inputs.nixhw.nixosModules.common-amd-gpu
inputs.nixhw.nixosModules.common-bluetooth
inputs.nixhw.nixosModules.common-ssd
self.inputs.nixhw.nixosModules.common-amd-cpu
self.inputs.nixhw.nixosModules.common-amd-gpu
self.inputs.nixhw.nixosModules.common-bluetooth
self.inputs.nixhw.nixosModules.common-ssd
self.inputs.raffauflabs.nixosModules.raffauflabs
];
age.secrets = {

View file

@ -1,6 +1,5 @@
{
config,
inputs,
lib,
pkgs,
self,

View file

@ -1,16 +1,16 @@
# Lenovo Yoga 9i Convertible with Intel Core i7-1360P, 16GB RAM, 512GB SSD.
{
config,
inputs,
lib,
pkgs,
self,
...
}: {
imports = [
../common.nix
./disko.nix
./home.nix
inputs.nixhw.nixosModules.lenovo-yoga-9i-intel-13th
self.inputs.nixhw.nixosModules.lenovo-yoga-9i-intel-13th
];
age.secrets = {

View file

@ -1,8 +1,8 @@
{
config,
inputs,
lib,
pkgs,
self,
...
}: {
home-manager = {
@ -10,10 +10,10 @@
{
wayland.windowManager.hyprland.extraConfig = ''
# Extra bindings for petalburg.
bind = , xf86launch4, exec, ${lib.getExe inputs.nixhw.packages.${pkgs.system}.power-profile-adjuster}
bind = , xf86launch4, exec, ${lib.getExe self.inputs.nixhw.packages.${pkgs.system}.power-profile-adjuster}
bind = , xf86launch2, exec, ${lib.getExe pkgs.playerctl} play-pause
exec-once = ${lib.getExe inputs.iio-hyprland.packages.${pkgs.system}.default} "desc:Samsung Display Corp. 0x4152"
exec-once = ${lib.getExe self.inputs.iio-hyprland.packages.${pkgs.system}.default} "desc:Samsung Display Corp. 0x4152"
'';
ar.home.desktop.hyprland.tabletMode.enable = true;

View file

@ -1,7 +1,6 @@
# Lenovo Thinkpad T440p with a Core i5 4210M, 16GB RAM, 512GB SSD.
{
config,
inputs,
lib,
pkgs,
self,
@ -11,7 +10,7 @@
../common.nix
./disko.nix
./home.nix
inputs.nixhw.nixosModules.thinkpad-t440p
self.inputs.nixhw.nixosModules.thinkpad-t440p
];
age.secrets = {

View file

@ -1,6 +1,5 @@
{
config,
inputs,
lib,
pkgs,
...

View file

@ -1,4 +1,4 @@
inputs: {
self: {
config,
pkgs,
lib,

View file

@ -1,4 +1,4 @@
inputs: {
self: {
config,
pkgs,
lib,