dots/flake.nix

295 lines
8.9 KiB
Nix
Raw Normal View History

2023-11-30 00:49:32 -06:00
{
description = "Price Hiller's home manager configuration";
inputs = {
2024-05-03 14:35:00 -05:00
nix.url = "github:nixos/nix";
deploy-rs.url = "github:serokell/deploy-rs";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
2024-02-13 12:31:59 -06:00
flake-utils.url = "github:numtide/flake-utils";
bob = {
2024-05-03 14:35:00 -05:00
flake = false;
url = "github:MordechaiHadad/bob";
};
2023-11-30 00:49:32 -06:00
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-02-13 09:29:46 -06:00
waybar = {
url = "github:Alexays/Waybar";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-11-30 00:49:32 -06:00
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
wezterm = {
url = "github:wez/wezterm?dir=nix";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-02-29 02:07:22 -06:00
nixgl.url = "github:guibou/nixGL";
agenix = {
url = "github:yaxitech/ragenix";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-05-03 14:35:00 -05:00
impermanence = {
url = "github:nix-community/impermanence";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
blog = {
url = "git+https://git.orion-technologies.io/blog/blog";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-11-30 00:49:32 -06:00
};
2024-04-19 22:27:46 -05:00
outputs =
2024-05-03 14:35:00 -05:00
inputs@{ self, nixpkgs, ... }:
2023-11-30 00:49:32 -06:00
let
2024-05-03 14:35:00 -05:00
inherit (self) outputs;
forAllSystems =
function:
nixpkgs.lib.genAttrs
[
"aarch64-linux"
"i686-linux"
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
]
(
system:
function (
import nixpkgs {
inherit system;
overlays = [
inputs.agenix.overlays.default
2024-05-24 14:04:26 -05:00
inputs.neovim-nightly-overlay.overlays.default
self.overlays.modifications
self.overlays.additions
2024-05-03 14:35:00 -05:00
];
}
)
);
mkHomeCfg =
user: home-config:
let
username = "${builtins.head (builtins.match "(.+)(@.+)?" user)}";
in
inputs.home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
extraSpecialArgs = {
inherit inputs;
};
modules = [
({
imports = [ inputs.agenix.homeManagerModules.default ];
nixpkgs.overlays = [
2024-05-24 14:04:26 -05:00
inputs.neovim-nightly-overlay.overlays.default
2024-05-03 14:35:00 -05:00
inputs.nixgl.overlay
self.overlays.modifications
self.overlays.additions
2024-02-04 22:26:55 -06:00
];
2024-05-03 14:35:00 -05:00
home = {
stateVersion = "24.05";
username = "${username}";
homeDirectory = "/home/${username}";
};
})
home-config
];
2024-02-04 22:26:55 -06:00
};
2024-05-03 14:35:00 -05:00
in
{
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
packages = forAllSystems (pkgs: import ./pkgs pkgs);
homeConfigurations = builtins.mapAttrs (mkHomeCfg) {
"price@orion" = ./users/price/home.nix;
"sam" = ./users/sam/home.nix;
2024-04-19 22:27:46 -05:00
};
2024-05-03 14:35:00 -05:00
overlays = import ./overlays { inherit inputs; };
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
age
agenix
age-plugin-yubikey
nixos-rebuild
2024-05-03 14:35:00 -05:00
nixos-install-tools
pkgs.deploy-rs
];
shellHook = ''
export RULES="$PWD/secrets/secrets.nix"
'';
};
2024-05-03 14:35:00 -05:00
});
2024-05-10 00:02:07 -05:00
checks = forAllSystems (pkgs: {
formatting =
pkgs.runCommand "check-fmt"
{
buildInputs = with pkgs; [
findutils
(import ./pkgs { inherit pkgs; }).Fmt
];
}
''
set -euo pipefail
cd "${self}"
find . -type f | xargs Fmt
touch $out
'';
});
2024-05-03 14:35:00 -05:00
apps = forAllSystems (pkgs: {
home-manager-init = {
type = "app";
program = "${
pkgs.writeShellApplication {
name = "home-manager-init";
runtimeInputs = with pkgs; [
git
nix
];
text = ''
#!${pkgs.bash}/bin/bash
cd "$(git rev-parse --show-toplevel)"
nix run --extra-experimental-features 'nix-command flakes' github:nix-community/home-manager -- switch --extra-experimental-features 'nix-command flakes' --flake "git+file://$(pwd)?submodules=1" "$@"
'';
}
}/bin/home-manager-init";
};
install-host = {
type = "app";
program = "${
pkgs.writeShellApplication {
name = "install-host";
runtimeInputs = with pkgs; [
openssh
coreutils-full
git
agenix
nix
];
text = (
''
#!${pkgs.bash}/bin/bash
# The below `cd` invocation ensures the installer is running from the toplevel of
# the flake and thus has correct paths available.
cd "$(git rev-parse --show-toplevel)"
''
+ builtins.readFile ./scripts/install-host.bash
);
}
}/bin/install-host";
};
});
nixosConfigurations =
let
lib = (import ./lib { lib = nixpkgs.lib; }) // nixpkgs.lib;
persist-dir = "/persist";
defaults = {
config = {
2024-05-24 14:04:26 -05:00
nixpkgs.overlays = [ inputs.neovim-nightly-overlay.overlays.default ];
2024-05-03 14:35:00 -05:00
environment.etc.machine-id.source = "${persist-dir}/ephemeral/etc/machine-id";
environment.persistence.save = {
hideMounts = true;
persistentStoragePath = "${persist-dir}/save";
};
environment.persistence.ephemeral = {
persistentStoragePath = "${persist-dir}/ephemeral";
hideMounts = true;
directories = [
"/var/lib"
"/etc/nixos"
];
};
};
};
in
{
orion =
let
hostname = "orion";
in
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit self;
inherit inputs;
inherit outputs;
inherit hostname;
inherit lib;
inherit persist-dir;
root-disk = "/dev/nvme0n1";
2024-05-03 14:35:00 -05:00
};
modules = [
defaults
inputs.impermanence.nixosModules.impermanence
inputs.agenix.nixosModules.default
inputs.disko.nixosModules.disko
{
config =
(import "${self}/secrets" {
agenix = false;
inherit lib;
}).${hostname};
}
./hosts/${hostname}
];
};
luna =
let
hostname = "luna";
in
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit self;
inherit inputs;
inherit hostname;
inherit nixpkgs;
inherit lib;
inherit persist-dir;
root-disk = "/dev/nvme0n1";
fqdn = "orion-technologies.io";
};
modules = [
defaults
inputs.impermanence.nixosModules.impermanence
inputs.agenix.nixosModules.default
inputs.disko.nixosModules.disko
{
config =
(import "${self}/secrets" {
agenix = false;
inherit lib;
}).${hostname};
}
./hosts/${hostname}
];
};
};
deploy.nodes =
let
deploy-rs = inputs.deploy-rs;
in
{
orion = {
hostname = "orion";
fastConnection = true;
profiles.system = {
sshUser = "price";
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos outputs.nixosConfigurations.orion;
};
};
luna = {
hostname = "luna.hosts.orion-technologies.io";
fastConnection = true;
profiles.system = {
sshUser = "price";
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos outputs.nixosConfigurations.luna;
};
};
};
};
2023-11-30 00:49:32 -06:00
}