nixos-config/flake.nix

273 lines
6.8 KiB
Nix
Raw Normal View History

2023-03-29 13:14:37 +00:00
{
inputs = {
# Pin nixpkgs to a specific commit
2024-07-17 03:45:15 +00:00
nixpkgs.url = "github:xinyangli/nixpkgs/deploy";
2024-07-14 06:04:52 +00:00
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
2023-03-29 13:14:37 +00:00
2023-04-16 02:30:45 +00:00
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-01-13 02:47:37 +00:00
nix-vscode-extensions = {
2023-09-26 18:32:27 +00:00
url = "github:nix-community/nix-vscode-extensions";
inputs.nixpkgs.follows = "nixpkgs";
2023-12-15 13:24:46 +00:00
inputs.flake-utils.follows = "flake-utils";
2023-09-26 18:32:27 +00:00
};
2023-04-16 05:18:23 +00:00
2023-09-11 12:20:32 +00:00
nur = {
url = "github:nix-community/NUR";
};
2023-03-29 13:14:37 +00:00
2023-09-11 12:20:32 +00:00
nixos-hardware = {
url = "github:NixOS/nixos-hardware/master";
};
2023-04-16 02:30:45 +00:00
2023-09-11 12:20:32 +00:00
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-09-11 12:20:32 +00:00
flake-utils = {
url = "github:numtide/flake-utils";
};
colmena = {
url = "github:zhaofengli/colmena";
inputs.stable.follows = "nixpkgs";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
2023-12-15 13:24:46 +00:00
nix-index-database = {
url = "github:Mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-08-20 13:04:46 +00:00
my-nixvim = {
url = "git+https://git.xinyang.life/xin/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-09-05 01:19:16 +00:00
catppuccin = {
url = "github:catppuccin/nix";
};
stylix = {
url = "github:xinyangli/stylix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
2023-04-03 09:41:33 +00:00
};
outputs =
2024-08-25 09:45:58 +00:00
{
self,
home-manager,
nixpkgs,
nixos-hardware,
flake-utils,
nur,
catppuccin,
my-nixvim,
...
2024-08-20 13:14:45 +00:00
}@inputs:
2023-04-16 02:30:45 +00:00
let
2024-08-25 09:45:58 +00:00
nixvimOverlay = (final: prev: { nixvim = self.packages.${prev.stdenv.system}.nixvim; });
overlayModule =
{ ... }:
{
nixpkgs.overlays = [
nixvimOverlay
(import ./overlays/add-pkgs.nix)
];
};
2024-08-20 13:04:46 +00:00
deploymentModule = {
deployment.targetUser = "xin";
};
sharedColmenaModules = [
self.nixosModules.default
deploymentModule
];
sharedHmModules = [
inputs.sops-nix.homeManagerModules.sops
inputs.nix-index-database.hmModules.nix-index
catppuccin.homeManagerModules.catppuccin
self.homeManagerModules
];
2024-08-25 09:45:58 +00:00
mkHome =
user: host:
{ ... }:
{
imports = [
home-manager.nixosModules.home-manager
{
home-manager = {
sharedModules = sharedHmModules;
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs;
};
};
home-manager.users.${user} = (import ./home).${user}.${host};
}
];
};
mkHomeConfiguration = user: host: {
name = user;
value = home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs { system = "x86_64-linux"; };
modules = [
(import ./home).${user}.${host}
2024-08-20 13:14:45 +00:00
overlayModule
] ++ sharedHmModules;
2024-01-07 13:41:01 +00:00
extraSpecialArgs = {
inherit inputs;
};
};
};
2024-08-25 09:45:58 +00:00
mkNixos =
{
system,
modules,
specialArgs ? { },
}:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = specialArgs // {
inherit inputs system;
};
modules = [
self.nixosModules.default
nur.nixosModules.nur
] ++ modules;
};
2023-04-16 02:30:45 +00:00
in
{
2024-07-30 02:59:12 +00:00
nixpkgs = nixpkgs;
2024-08-25 09:45:58 +00:00
nixosModules.default = {
imports = [
./modules/nixos
overlayModule
];
};
2023-04-16 02:30:45 +00:00
homeManagerModules = import ./modules/home-manager;
2024-01-07 13:41:01 +00:00
homeConfigurations = builtins.listToAttrs [ (mkHomeConfiguration "xin" "calcite") ];
2024-08-20 13:04:46 +00:00
colmenaHive = inputs.colmena.lib.makeHive {
2024-08-20 13:14:45 +00:00
meta = {
2024-08-25 09:45:58 +00:00
nixpkgs = import nixpkgs { system = "x86_64-linux"; };
2024-08-20 13:14:45 +00:00
specialArgs = {
inherit inputs;
};
};
2023-10-06 14:03:47 +00:00
2024-08-25 09:45:58 +00:00
massicot =
{ ... }:
{
deployment.targetHost = "49.13.13.122";
deployment.buildOnTarget = true;
2024-08-25 09:45:58 +00:00
imports = [
{ nixpkgs.system = "aarch64-linux"; }
machines/massicot
] ++ sharedColmenaModules;
};
2023-11-28 13:38:50 +00:00
2024-08-25 09:45:58 +00:00
tok-00 =
{ ... }:
{
imports = [ machines/dolomite ] ++ sharedColmenaModules;
nixpkgs.system = "x86_64-linux";
networking.hostName = "tok-00";
system.stateVersion = "23.11";
deployment = {
targetHost = "video01.namely.icu";
buildOnTarget = false;
tags = [ "proxy" ];
};
2023-11-28 13:38:50 +00:00
};
2023-12-06 14:54:22 +00:00
2024-08-25 09:45:58 +00:00
la-00 =
{ ... }:
{
imports = [ machines/dolomite ] ++ sharedColmenaModules;
nixpkgs.system = "x86_64-linux";
networking.hostName = "la-00";
system.stateVersion = "21.05";
deployment = {
targetHost = "la-00.video.namely.icu";
buildOnTarget = false;
tags = [ "proxy" ];
};
2023-12-06 14:54:22 +00:00
};
2024-08-25 09:45:58 +00:00
raspite =
{ ... }:
{
deployment = {
targetHost = "raspite.local";
buildOnTarget = false;
};
nixpkgs.system = "aarch64-linux";
imports = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
nixos-hardware.nixosModules.raspberry-pi-4
machines/raspite/configuration.nix
] ++ sharedColmenaModules;
};
2024-08-25 09:45:58 +00:00
weilite =
{ ... }:
{
imports = [ machines/weilite ] ++ sharedColmenaModules;
deployment = {
targetHost = "weilite.coho-tet.ts.net";
targetPort = 22;
buildOnTarget = false;
};
nixpkgs.system = "x86_64-linux";
};
2024-08-20 13:14:45 +00:00
};
2023-10-06 14:03:47 +00:00
nixosConfigurations = {
calcite = mkNixos {
system = "x86_64-linux";
modules = [
nixos-hardware.nixosModules.asus-zephyrus-ga401
machines/calcite/configuration.nix
(mkHome "xin" "calcite")
];
};
} // self.colmenaHive.nodes;
2023-04-16 05:18:23 +00:00
2024-08-25 09:45:58 +00:00
}
// flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells = {
default = pkgs.mkShell {
packages = with pkgs; [
nix
git
colmena
sops
nix-output-monitor
nil
nvd
];
};
};
2024-08-20 13:04:46 +00:00
2024-08-25 09:45:58 +00:00
packages = {
nixvim = my-nixvim.packages.${system}.default;
};
}
);
2023-03-29 13:14:37 +00:00
}