dotfiles/flake.nix

215 lines
6.4 KiB
Nix

{
description = "NixOS configuration with flakes";
outputs = { self, flake-utils, home-manager, nixpkgs-nixos-unstable
, nixpkgs-stable, darwin, nixos-hardware, nur, sops, }@inputs:
let
mkServer = pkgs: system: hostname:
pkgs.lib.nixosSystem {
inherit system;
modules =
[ (./. + "/nixos/boxes/${hostname}") sops.nixosModules.sops ];
specialArgs = { inherit inputs; };
};
mkRaspi = pkgs: hostname:
pkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [ (./. + "/nixos/boxes/${hostname}") ];
specialArgs = { inherit inputs; };
};
mkWorkstation = pkgs: system: hostname:
pkgs.lib.nixosSystem {
inherit system;
modules = [
(./. + "/nixos/boxes/${hostname}")
(import ./nixos/email-accounts.nix)
sops.nixosModules.sops
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.cyryl = {
imports =
[ ./nixos/home-manager ./nixos/home-manager/linux.nix ];
_module.args.inputs = inputs;
};
}
];
specialArgs = {
inherit inputs system;
nixpkgs-nixos-unstable-and-unfree = import nixpkgs-nixos-unstable {
inherit system;
config = { allowUnfree = true; };
};
};
};
in rec {
devShell."x86_64-darwin" =
nixpkgs-stable.legacyPackages."x86_64-darwin".mkShell {
buildInputs =
with nixpkgs-nixos-unstable.legacyPackages."x86_64-darwin"; [
cacert
git
nixFlakes
nixpkgs-fmt
openssh
openssl
pkg-config
statix
];
};
devShell."x86_64-linux" =
nixpkgs-stable.legacyPackages."x86_64-linux".mkShell {
buildInputs =
with nixpkgs-nixos-unstable.legacyPackages."x86_64-linux"; [
cacert
git
nixFlakes
nixpkgs-fmt
openssh
openssl
pkg-config
statix
];
};
darwinConfigurations = {
"macmini" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
(./. + "/nixos/boxes/macmini")
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.cyryl = {
imports = [ ./nixos/home-manager ];
};
}
];
};
"FORM3-CYRYLPLOTN" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
(./. + "/nixos/boxes/form3")
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.cyryl = {
imports = [ ./nixos/home-manager ];
_module.args.inputs = inputs;
};
}
];
};
};
nixosConfigurations = {
foureighty = mkWorkstation nixpkgs-stable "x86_64-linux" "foureighty";
skinnyv = mkWorkstation nixpkgs-stable "x86_64-linux" "skinnyv";
thinky = mkWorkstation nixpkgs-stable "x86_64-linux" "thinky";
bolty = mkServer nixpkgs-stable "x86_64-linux" "bolty";
vultr1 = mkServer nixpkgs-stable "x86_64-linux" "vultr1";
vpsfree1 = mkServer nixpkgs-stable "x86_64-linux" "vpsfree1";
rpi4_8 = mkRaspi nixpkgs-stable "rpi4-8";
bootstrap = nixpkgs-stable.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [ (./. + "/nixos/boxes/bootstrap") ];
specialArgs = {
inherit inputs system;
nixpkgs-nixos-unstable-and-unfree = import nixpkgs-nixos-unstable {
inherit system;
config = { allowUnfree = true; };
};
};
};
# 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
raspiimage = nixpkgs-stable.lib.nixosSystem {
system = "aarch64-linux";
modules = [
(import
"${inputs.nixpkgs-nixos-unstable}/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix")
{
services.openssh = {
enable = true;
permitRootLogin =
inputs.nixpkgs-stable.lib.mkForce "prohibit-password";
passwordAuthentication = false;
};
users.extraUsers.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE5Ejx5CAPUfHVXi4GL4WmnZaG8eiiOmsW/a0o1bs1GF cyryl@foureighty"
];
sdImage.compressImage = false;
console.earlySetup = true;
}
];
specialArgs = { inherit inputs; };
};
};
};
inputs = {
nixpkgs-nixos-unstable = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
};
nixpkgs-stable = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-22.05";
};
nixos-hardware = {
type = "github";
owner = "NixOS";
repo = "nixos-hardware";
ref = "master";
};
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
home-manager = {
type = "github";
owner = "nix-community";
repo = "home-manager";
ref = "release-22.05";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
flake-utils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
ref = "master";
};
nur = {
type = "github";
owner = "nix-community";
repo = "NUR";
ref = "master";
};
sops = {
type = "github";
owner = "Mic92";
repo = "sops-nix";
ref = "master";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
};
}