System/flake.nix

263 lines
8.5 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";
};
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, 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
./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 ];
};
})
] ++ 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 = [
./hardware/levitation.nix
./machines/levitation/configuration.nix
];
};
oracles = makeNixosSystem {
system = "x86_64-linux";
hostName = "oracles";
extraModules =
[ ./hardware/oracles.nix ./machines/oracles/configuration.nix ];
};
matrix = makeNixosSystem {
system = "x86_64-linux";
hostName = "matrix";
extraModules =
[ ./hardware/matrix.nix ./machines/matrix/configuration.nix ];
};
tounge = makeNixosSystem {
system = "aarch64-linux";
hostName = "tounge";
extraModules = [ ./machines/tounge/configuration.nix ];
};
perception = makeNixosSystem {
system = "x86_4-linux";
hostName = "perception";
extraModules = [
./machines/perception/configuration.nix
./hardware/perception.nix
];
};
fusion = makeNixosSystem {
system = "aarch64-linux";
hostName = "fusion";
extraModules =
[ ./machines/fusion/configuration.nix ./hardware/fusion.nix ];
};
x86vm = makeNixosSystem {
system = "x86_64-linux";
hostName = "x86vm";
extraModules = [
"${nixpkgs}/nixos/modules/profiles/qemu-guest.nix"
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
./machines/x86vm/configuration.nix
];
};
# WSL sytem
wsl = makeNixosSystem {
system = "x86_64-linux";
hostName = "wsl";
extraModules =
[ wsl.nixosModules.wsl ./machines/wsl/configuration.nix ];
};
# VMs
productivity-vm = makeNixosSystem {
system = "x86_64-linux";
hostName = "productivity-vm";
extraModules = [
./machines/productivity-vm/configuration.nix
./hardware/productivity-vm.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 ];
};
})
];
};
};
packages = {
x86_64-linux = {
# Hyper-V image
hyperv = nixos-generators.nixosGenerate {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
modules = [ ./machines/hyperv/configuration.nix ];
format = "hyperv";
};
};
};
} // 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 = flake-utils.lib.flattenTree {
discordWayland = pkgs.callPackage ./packages/discord/default.nix rec {
pname = "discord-electron";
binaryName = "DiscordCanary";
desktopName = "Discord (Wayland)";
version = "0.0.156";
src = pkgs.fetchurl {
url =
"https://dl-canary.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz";
hash = "sha256-W28AGQEeTkjZjRckEputN41wAPwyAm349uNlXYfZTCs=";
};
electron = pkgs.electron_22;
};
swayimg = pkgs.callPackage ./packages/swayimg/default.nix { };
layman = pkgs.callPackage ./packages/layman/default.nix { };
};
});
}