System/flake.nix

302 lines
10 KiB
Nix

{
description = "Nathan's system configurations";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware";
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland.url = "github:hyprwm/Hyprland";
hyprland-contrib.url = "github:hyprwm/contrib";
nix-on-droid = {
url = "github:t184256/nix-on-droid";
inputs = {
nixpkgs.follows = "nixpkgs";
home-manager.follows = "home-manager";
};
};
flake-utils.url = "github:numtide/flake-utils";
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
emacs = {
url =
"github:nix-community/emacs-overlay/9b41f8296a3898bdb87b9d091f9df540a982b242";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
java = {
url = "git+https://git.stranger.systems/nix/java";
inputs.nixpkgs.follows = "nixpkgs";
};
quilt-server = {
url = "github:forward-progress/quilt-server-nix-container";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
wsl = {
url = "github:nix-community/NixOS-WSL";
inputs.nixpkgs.follows = "nixpkgs";
};
idris2 = {
url = "github:idris-lang/idris2";
inputs.nixpkgs.follows = "nixpkgs";
};
scripts.url = "git+https://git.sr.ht/~thatonelutenist/Scripts?ref=trunk";
};
outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils, sops-nix
, home-manager, hyprland, darwin, nixos-generators, wsl, nix-on-droid, ...
}@inputs:
let
makeNixosSystem =
{ system, hostName, extraModules ? [ ], ourNixpkgs ? nixpkgs }:
ourNixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inputs = inputs; };
modules = [
sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager
hyprland.nixosModules.default
./modules/linux/default.nix
({ pkgs, lib, config, ... }: {
# Configure hostname
networking = { hostName = hostName; };
# Setup sops
# Add default secrets
sops = { age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; };
nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowUnfreePredicate = (pkg: true);
# Home manager configuration
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
extraSpecialArgs = {
inputs = inputs;
nixosConfig = config;
};
sharedModules = [
./home-manager/linux/default.nix
hyprland.homeManagerModules.default
];
};
})
] ++ extraModules;
};
makeDarwinSystem = { system, extraModules ? [ ] }:
darwin.lib.darwinSystem {
inherit system;
specialArgs = { inputs = inputs; };
modules = [
home-manager.darwinModules.home-manager
./modules/darwin/default.nix
({ pkgs, lib, config, ... }: {
nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowUnfreePredicate = (pkg: true);
# Home manager configuration
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
extraSpecialArgs = {
inputs = inputs;
nixosConfig = config;
};
sharedModules = [ ./home-manager/darwin/default.nix ];
};
})
] ++ extraModules;
};
in rec {
# Real systems
nixosConfigurations = {
levitation = makeNixosSystem {
system = "x86_64-linux";
hostName = "levitation";
extraModules = [
./machines/levitation/configuration.nix
./machines/levitation/hardware.nix
];
};
oracles = makeNixosSystem {
system = "x86_64-linux";
hostName = "oracles";
extraModules = [
./machines/oracles/hardware.nix
./machines/oracles/configuration.nix
];
};
tounge = makeNixosSystem {
system = "aarch64-linux";
hostName = "tounge";
extraModules = [ ./machines/tounge/configuration.nix ];
};
perception = makeNixosSystem {
system = "x86_64-linux";
hostName = "perception";
extraModules = [
./machines/perception/configuration.nix
./machines/perception/hardware.nix
];
};
fusion = makeNixosSystem {
system = "aarch64-linux";
hostName = "fusion";
extraModules = [
./machines/fusion/hardware.nix
./machines/fusion/configuration.nix
];
};
pendulum = makeNixosSystem {
system = "x86_64-linux";
hostName = "pendulum";
extraModules = [
./machines/pendulum/hardware.nix
./machines/pendulum/configuration.nix
];
};
# WSL sytem
wsl = makeNixosSystem {
system = "x86_64-linux";
hostName = "wsl";
extraModules = [
wsl.nixosModules.wsl
./machines/wsl/configuration.nix
({ ... }: { # Setup home manager
home-manager.users.nathan = import ./machines/wsl/home.nix;
})
];
};
wsl-bootstrap = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inputs = inputs; };
modules = [
sops-nix.nixosModules.sops
hyprland.nixosModules.default
./modules/linux/default.nix
({ pkgs, lib, config, ... }: {
# Configure hostname
networking = { hostName = "wsl"; };
# Setup sops
# Add default secrets
sops = { age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; };
nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowUnfreePredicate = (pkg: true);
})
wsl.nixosModules.wsl
./machines/wsl/configuration.nix
];
};
# VMs
productivity-vm = makeNixosSystem {
system = "x86_64-linux";
hostName = "productivity-vm";
extraModules = [
"${nixpkgs}/nixos/modules/profiles/qemu-guest.nix"
./machines/productivity-vm/configuration.nix
./machines/productivity-vm/hardware.nix
];
};
# Installer iso
iso_x86_64 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma5.nix"
"${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
];
};
};
# Mac systems
darwinConfigurations = {
"extremophile" = makeDarwinSystem {
system = "aarch64-darwin";
extraModules = [ ./machines/extremophile/configuration.nix ];
};
};
# Android systems
nixOnDroidConfigurations = {
tablet = nix-on-droid.lib.nixOnDroidConfiguration {
modules = [
./machines/tablet/configuration.nix
./modules/nix-on-droid/default.nix
({ pkgs, lib, config, ... }: {
# Home manager configuration
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
extraSpecialArgs = {
inputs = inputs;
nixosConfig = config;
};
sharedModules = [ ./home-manager/nix-on-droid/default.nix ];
};
})
];
};
};
} // flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
# Special handling for discord, as it's unfree _and_ insecure!
config = {
allowUnfree = true;
permittedInsecurePackages = [ "electron-16.2.3" ];
};
};
in {
packages = let
writePython311Script =
pkgs.writers.makePythonWriter pkgs.python311 pkgs.python311Packages
pkgs.buildPackages.python311Packages;
in flake-utils.lib.flattenTree {
discordWayland = pkgs.callPackage ./packages/discord/default.nix rec {
pname = "discord-electron";
binaryName = "DiscordCanary";
desktopName = "Discord (Wayland)";
version = "0.0.159";
src = pkgs.fetchurl {
url =
"https://dl-canary.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz";
hash = "sha256-rhfp07qojSDJoQayyEwzunHWOsXIR3S42vN4635KGDI=";
};
electron = pkgs.electron_22;
};
swayimg = pkgs.callPackage ./packages/swayimg/default.nix { };
hyprland-autoname-workspaces =
pkgs.callPackage ./packages/workspace-renamer/default.nix { };
pyprland = pkgs.callPackage ./packages/pyprland { };
shortcuts = let
script = writePython311Script "shortcuts" { }
(builtins.readFile ./scripts/shortcuts/shortcuts.py);
in pkgs.stdenv.mkDerivation {
name = "shortcuts";
src = ./shortcuts;
installPhase = ''
mkdir -p $out/bin
ln -s ${script} $out/bin/shortcuts
mkdir -p $out/shortcuts
cp -r * $out/shortcuts
'';
};
};
});
}