dotfiles/flake.nix

440 lines
14 KiB
Nix
Raw Normal View History

2021-05-30 20:41:33 +01:00
{
description = "NixOS configuration with flakes";
2024-04-21 18:17:38 +01:00
outputs = {
alejandra,
darwin,
disko,
endless-sky,
flake-compat,
flake-utils,
helix,
home-manager,
2024-07-12 12:24:17 +01:00
lix-module,
2024-04-21 18:17:38 +01:00
nil,
nix-ld,
nixos-hardware,
nixpkgs-master,
nixpkgs-nixos-unstable,
nixpkgs-rust-analyzer,
nixpkgs-stable,
nur,
self,
sops,
} @ inputs: let
mkServer = pkgs: system: hostname:
pkgs.lib.nixosSystem {
inherit system;
modules = [
(./. + "/nixos/boxes/${hostname}")
(import ./nixos/server-common.nix)
sops.nixosModules.sops
disko.nixosModules.disko
];
specialArgs = {inherit inputs system;};
};
mkPrivateServer = pkgs: system: hostname:
pkgs.lib.nixosSystem {
inherit system;
modules = [
(import ./nixos/options.nix)
(./. + "/nixos/boxes/${hostname}")
(import ./nixos/server-common.nix)
sops.nixosModules.sops
disko.nixosModules.disko
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.cyryl = {
imports = [./nixos/home-manager ./nixos/home-manager/linux.nix];
_module.args.inputs = inputs;
_module.args.system = system;
};
};
}
];
specialArgs = {inherit inputs system;};
};
2024-04-27 11:33:38 +01:00
mkRaspi = pkgs: hostname: let
system = "aarch64-linux";
in
2024-04-21 18:17:38 +01:00
pkgs.lib.nixosSystem {
2024-04-27 11:33:38 +01:00
inherit system;
2024-04-21 18:17:38 +01:00
modules = [(./. + "/nixos/boxes/${hostname}") sops.nixosModules.sops];
2024-04-27 11:33:38 +01:00
specialArgs = {inherit inputs system;};
2024-04-21 18:17:38 +01:00
};
mkKiosk = pkgs: system: hostname:
pkgs.lib.nixosSystem {
inherit system;
modules = [
(./. + "/nixos/boxes/${hostname}")
(import ./nixos/common.nix)
sops.nixosModules.sops
2021-05-31 09:15:44 +01:00
2024-04-21 18:17:38 +01:00
home-manager.nixosModules.home-manager
{
2024-04-27 11:33:38 +01:00
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.cyryl = {
imports = [./nixos/home-manager ./nixos/home-manager/linux.nix];
_module.args.inputs = inputs;
_module.args.system = system;
};
2022-03-08 00:17:06 +00:00
};
2024-04-21 18:17:38 +01:00
}
];
specialArgs = {
inherit inputs system;
nixpkgs-nixos-stable-and-unfree = import nixpkgs-stable {
inherit system;
config = {allowUnfree = true;};
};
nixpkgs-nixos-unstable-and-unfree = import nixpkgs-nixos-unstable {
inherit system;
config = {allowUnfree = true;};
2022-12-19 09:09:08 +00:00
};
};
2024-04-21 18:17:38 +01:00
};
mkWorkstation = pkgs: system: hostname:
pkgs.lib.nixosSystem {
inherit system;
modules = [
2024-07-12 12:24:17 +01:00
lix-module.nixosModules.default
(import ./nixos/options.nix)
2024-04-21 18:17:38 +01:00
(./. + "/nixos/boxes/${hostname}")
(import ./nixos/email-accounts.nix)
(import ./nixos/common.nix)
sops.nixosModules.sops
disko.nixosModules.disko
nix-ld.nixosModules.nix-ld
{programs.nix-ld.dev.enable = true;}
home-manager.nixosModules.home-manager
{
2024-04-27 11:33:38 +01:00
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.cyryl = {
imports = [./nixos/home-manager ./nixos/home-manager/linux.nix];
_module.args.inputs = inputs;
_module.args.system = system;
};
};
2024-04-21 18:17:38 +01:00
}
];
specialArgs = {
inherit inputs system;
nixpkgs-nixos-stable-and-unfree = import nixpkgs-stable {
inherit system;
config = {allowUnfree = true;};
};
nixpkgs-nixos-unstable =
import nixpkgs-nixos-unstable {inherit system;};
nixpkgs-nixos-unstable-and-unfree = import nixpkgs-nixos-unstable {
inherit system;
config = {allowUnfree = true;};
};
2021-12-04 09:20:11 +00:00
};
2022-10-29 21:22:35 +01:00
};
2024-04-21 18:17:38 +01:00
mkShell = packageSet: system: let
pkgs = packageSet.legacyPackages.${system};
in
pkgs.mkShell {
packages = with pkgs; [
inputs.alejandra.defaultPackage.${system}
cacert
git
git-lfs
nixpkgs-fmt
openssh
openssl
pkg-config
statix
];
2023-08-13 17:00:41 +01:00
};
2024-04-21 18:17:38 +01:00
in {
devShells = {
"x86_64-darwin".default = mkShell nixpkgs-stable "x86_64-darwin";
2024-06-28 20:24:15 +01:00
"aarch64-darwin".default = mkShell nixpkgs-stable "aarch64-darwin";
2024-04-21 18:17:38 +01:00
"x86_64-linux".default = mkShell nixpkgs-stable "x86_64-linux";
"aarch64-linux".default = mkShell nixpkgs-stable "aarch64-linux";
};
2024-06-28 19:23:39 +01:00
# Expose the package set, including overlays, for convenience.
darwinPackages = self.darwinConfigurations."airy".pkgs;
2024-04-21 18:17:38 +01:00
darwinConfigurations = {
2024-09-27 11:25:11 +01:00
"cushy" = darwin.lib.darwinSystem rec {
system = "aarch64-darwin";
modules = [
lix-module.nixosModules.default
(import ./nixos/options.nix)
2024-09-27 11:25:11 +01:00
(./. + "/nixos/boxes/cushy")
2024-10-02 13:25:26 +01:00
{users.users."Cyryl.Plotnicki".home = "/Users/Cyryl.Plotnicki";}
2024-09-27 11:25:11 +01:00
home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
2024-10-02 13:25:26 +01:00
users."Cyryl.Plotnicki" = {
2024-10-02 14:38:34 +01:00
home.username = "Cyryl.Plotnicki";
2024-09-27 11:25:11 +01:00
home.homeDirectory = "/Users/Cyryl.Plotnicki";
programs.zsh.loginExtra = ''
eval "$(/opt/homebrew/bin/brew shellenv)"
'';
imports = [./nixos/home-manager];
_module.args.inputs = inputs;
_module.args.system = system;
};
};
}
];
};
2024-06-28 19:23:39 +01:00
"airy" = darwin.lib.darwinSystem rec {
system = "aarch64-darwin";
2024-04-21 18:17:38 +01:00
modules = [
2024-07-12 12:24:17 +01:00
lix-module.nixosModules.default
(import ./nixos/options.nix)
2024-06-28 19:23:39 +01:00
(./. + "/nixos/boxes/airy")
{users.users.cyryl.home = "/Users/cyryl";}
2024-04-21 18:17:38 +01:00
home-manager.darwinModules.home-manager
{
2024-04-27 11:33:38 +01:00
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.cyryl = {
2024-06-28 19:23:39 +01:00
home.homeDirectory = "/Users/cyryl";
2024-08-13 19:11:46 +01:00
programs.zsh.loginExtra = ''
eval "$(/opt/homebrew/bin/brew shellenv)"
'';
2024-04-27 11:33:38 +01:00
imports = [./nixos/home-manager];
_module.args.inputs = inputs;
_module.args.system = system;
};
2024-04-21 18:17:38 +01:00
};
}
];
};
};
2022-03-10 12:21:27 +00:00
2024-04-21 18:17:38 +01:00
nixosConfigurations = {
foryog = mkWorkstation nixpkgs-nixos-unstable "x86_64-linux" "foryog";
thinky = mkWorkstation nixpkgs-stable "x86_64-linux" "thinky";
bolty = mkPrivateServer nixpkgs-stable "x86_64-linux" "bolty";
2024-04-21 18:17:38 +01:00
cupsnet = mkServer nixpkgs-stable "aarch64-linux" "cupsnet";
mb1 = mkServer nixpkgs-stable "x86_64-linux" "mb1";
2024-07-17 10:04:10 +01:00
airnix = mkServer nixpkgs-stable "aarch64-linux" "airnix";
2024-04-21 18:17:38 +01:00
homescreen = mkRaspi nixpkgs-stable "homescreen";
2021-12-04 10:43:02 +00:00
2024-04-21 18:17:38 +01:00
bootstrap = nixpkgs-stable.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [(./. + "/nixos/boxes/bootstrap") sops.nixosModules.sops];
specialArgs = {
inherit inputs system;
nixpkgs-nixos-unstable-and-unfree = import nixpkgs-nixos-unstable {
inherit system;
config = {allowUnfree = true;};
2022-03-02 22:46:45 +00:00
};
2021-12-04 09:20:11 +00:00
};
2024-04-21 18:17:38 +01:00
};
# nix build .#nixosConfigurations.raspiimage.config.system.build.sdImage
# sudo dd if=result/sd-image/nixos-sd-image-21.11.20211201.a640d83-aarch64-linux.img of=/dev/sda bs=4M conv=fsync status=progress
# make sure to update eeprom https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_4#Board-specific_installation_notes
raspiimage = nixpkgs-stable.lib.nixosSystem {
system = "aarch64-linux";
modules = [
(import
"${inputs.nixpkgs-stable}/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix")
{
environment.systemPackages = with nixpkgs-nixos-unstable.legacyPackages."aarch64-linux"; [
neovim
htop
btop
atop
];
2022-08-04 09:55:56 +01:00
2024-04-21 18:17:38 +01:00
networking.networkmanager.enable = false;
hardware.enableRedistributableFirmware = true;
networking.wireless.enable = true;
2022-08-04 09:55:56 +01:00
2024-04-21 18:17:38 +01:00
services.openssh = {
enable = true;
permitRootLogin =
nixpkgs-stable.lib.mkForce "prohibit-password";
passwordAuthentication = false;
};
2022-08-04 09:55:56 +01:00
2024-05-07 17:41:56 +01:00
services.xserver = {
enable = true;
displayManager.lightdm.enable = true;
desktopManager.gnome.enable = true;
libinput.enable = true;
};
users.extraUsers.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEo4R+6J3h6Ix3xWpOMdU7Es1/YxFchHw0c+kcCOJxFb cyryl@foureighty"
];
sdImage.compressImage = false;
console.earlySetup = true;
}
];
specialArgs = {inherit inputs;};
};
novenaimage = nixpkgs-stable.lib.nixosSystem {
system = "armv7l-linux";
modules = [
(import
"${inputs.nixpkgs-stable}/nixos/modules/installer/sd-card/sd-image-armv7l-multiplatform-installer.nix")
{
environment.systemPackages = with nixpkgs-nixos-unstable.legacyPackages."armv7l-linux"; [
neovim
htop
btop
atop
];
boot.kernelPackages = nixpkgs-stable.lib.mkForce nixpkgs-nixos-unstable.legacyPackages."armv7l-linux".linuxPackages_latest;
boot.supportedFilesystems = nixpkgs-stable.lib.mkForce ["ext2" "ext4"];
networking.networkmanager.enable = false;
hardware.enableRedistributableFirmware = true;
networking.wireless.enable = true;
services.openssh = {
enable = true;
permitRootLogin =
nixpkgs-stable.lib.mkForce "prohibit-password";
passwordAuthentication = false;
};
2024-04-21 18:17:38 +01:00
services.xserver = {
enable = true;
displayManager.lightdm.enable = true;
desktopManager.gnome.enable = true;
libinput.enable = true;
};
2022-08-04 09:55:56 +01:00
2024-04-21 18:17:38 +01:00
users.extraUsers.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEo4R+6J3h6Ix3xWpOMdU7Es1/YxFchHw0c+kcCOJxFb cyryl@foureighty"
];
sdImage.compressImage = false;
console.earlySetup = true;
}
];
specialArgs = {inherit inputs;};
2021-06-26 19:12:31 +01:00
};
2021-05-31 09:15:44 +01:00
};
2024-04-21 18:17:38 +01:00
};
2021-05-30 20:41:33 +01:00
inputs = {
2022-07-03 18:50:30 +01:00
nixpkgs-master = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "master";
};
2021-06-01 14:30:39 +01:00
nixpkgs-nixos-unstable = {
2021-05-30 20:41:33 +01:00
type = "github";
2021-05-30 23:13:31 +01:00
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
2021-05-30 20:41:33 +01:00
};
2021-05-31 09:15:44 +01:00
nixpkgs-stable = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
2024-12-01 12:08:22 +00:00
ref = "nixos-24.11";
2021-05-31 09:15:44 +01:00
};
2023-01-31 21:38:23 +00:00
nixpkgs-rust-analyzer = {
type = "github";
owner = "NixOS";
2023-01-31 21:38:23 +00:00
repo = "nixpkgs";
2023-11-30 10:00:47 +00:00
ref = "master";
2023-01-31 21:38:23 +00:00
};
2023-03-04 07:19:28 +00:00
endless-sky = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "2100c4926200b1ebbee032ad22113597195932f2";
};
2021-06-12 09:40:09 +01:00
nixos-hardware = {
type = "github";
owner = "NixOS";
2021-06-12 09:40:09 +01:00
repo = "nixos-hardware";
ref = "master";
2021-06-12 09:40:09 +01:00
};
2022-03-10 12:21:27 +00:00
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
2021-05-30 20:41:33 +01:00
home-manager = {
type = "github";
owner = "nix-community";
repo = "home-manager";
2024-12-01 12:08:22 +00:00
ref = "release-24.11";
2024-06-01 15:23:12 +01:00
inputs.nixpkgs.follows = "nixpkgs-stable";
2021-05-30 20:41:33 +01:00
};
2021-05-30 23:13:31 +01:00
flake-utils = {
2021-05-30 20:41:33 +01:00
type = "github";
2021-05-30 23:13:31 +01:00
owner = "numtide";
repo = "flake-utils";
ref = "main";
2021-05-30 20:41:33 +01:00
};
2024-07-12 12:24:17 +01:00
lix-module = {
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.90.0.tar.gz";
inputs.nixpkgs.follows = "nixpkgs-stable";
inputs.flake-utils.follows = "flake-utils";
};
2021-05-30 20:41:33 +01:00
nur = {
type = "github";
owner = "nix-community";
repo = "NUR";
ref = "master";
};
2022-10-01 13:37:46 +01:00
nil = {
type = "github";
owner = "oxalica";
repo = "nil";
2023-08-18 16:25:36 +01:00
ref = "main";
2022-10-01 13:37:46 +01:00
inputs.nixpkgs.follows = "nixpkgs-nixos-unstable";
inputs.flake-utils.follows = "flake-utils";
};
2023-12-18 21:02:29 +00:00
nix-ld = {
type = "github";
owner = "Mic92";
repo = "nix-ld";
ref = "main";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
2022-12-07 23:52:15 +00:00
helix = {
type = "github";
owner = "helix-editor";
repo = "helix";
2023-08-26 20:42:12 +01:00
ref = "master";
2023-06-22 10:42:53 +01:00
inputs.nixpkgs.follows = "nixpkgs-stable";
2023-12-18 10:28:15 +00:00
inputs.flake-utils.follows = "flake-utils";
2022-12-07 23:52:15 +00:00
};
2021-10-30 11:10:19 +01:00
sops = {
type = "github";
owner = "Mic92";
repo = "sops-nix";
ref = "master";
2022-06-04 08:40:14 +01:00
inputs.nixpkgs.follows = "nixpkgs-stable";
2021-10-30 11:10:19 +01:00
};
2022-12-19 09:09:08 +00:00
alejandra = {
2022-12-19 09:04:27 +00:00
type = "github";
owner = "kamadorueda";
repo = "alejandra";
ref = "main";
inputs.nixpkgs.follows = "nixpkgs-nixos-unstable";
};
2023-04-01 10:17:50 +01:00
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
2022-11-08 16:28:34 +00:00
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
2021-05-30 20:41:33 +01:00
};
}