nix-home/flake.nix

211 lines
7.1 KiB
Nix
Raw Normal View History

2021-10-26 18:25:19 +00:00
{
description = "nki's systems";
2021-10-26 18:25:19 +00:00
inputs = {
2022-12-05 09:59:59 +00:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
2023-04-18 11:03:19 +00:00
nixpkgs-unstable.url = "github:natsukagami/nixpkgs/nixpkgs-unstable";
# nixpkgs-unstable.follows = "nixos-m1/nixpkgs";
2021-10-26 18:25:19 +00:00
darwin.url = "github:lnl7/nix-darwin/master";
darwin.inputs.nixpkgs.follows = "nixpkgs-unstable";
2022-12-05 09:59:59 +00:00
home-manager.url = "github:natsukagami/home-manager/release-22.11";
2021-12-01 18:52:13 +00:00
home-manager.inputs.nixpkgs.follows = "nixpkgs";
2023-03-27 12:59:32 +00:00
home-manager-unstable.url = "github:nix-community/home-manager";
home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs-unstable";
sops-nix.url = "github:Mic92/sops-nix";
2022-11-14 14:25:54 +00:00
sops-nix.inputs.nixpkgs.follows = "nixpkgs-unstable";
2022-12-05 09:59:59 +00:00
sops-nix.inputs.nixpkgs-stable.follows = "nixpkgs";
deploy-rs.url = "github:Serokell/deploy-rs";
nur.url = "github:nix-community/NUR";
2021-10-29 04:25:58 +00:00
# --- Build tools
2022-05-31 16:45:33 +00:00
flake-utils.url = github:numtide/flake-utils;
crane.url = github:ipetkov/crane;
2022-05-31 16:45:33 +00:00
2021-10-29 04:25:58 +00:00
# ---
# Imported apps
rnix-lsp.url = "github:nix-community/rnix-lsp";
2021-11-03 19:01:23 +00:00
youmubot.url = "github:natsukagami/youmubot";
2022-04-30 00:07:50 +00:00
youmubot.inputs.nixpkgs.follows = "nixpkgs";
2021-12-09 20:54:26 +00:00
nix-gaming.url = github:fufexan/nix-gaming;
2023-03-23 10:17:12 +00:00
swayfx = {
url = github:WillPower3309/swayfx;
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
2023-03-31 08:26:13 +00:00
mpd-mpris = {
url = github:natsukagami/mpd-mpris/nix;
inputs.nixpkgs.follows = "nixpkgs";
};
# --- Sources
2023-01-26 09:59:28 +00:00
kakoune.url = github:mawww/kakoune;
kakoune.flake = false;
kak-lsp.url = github:natsukagami/kak-lsp/show-message-request;
kak-lsp.flake = false;
2023-02-25 20:43:29 +00:00
nixos-m1.url = github:tpwrules/nixos-apple-silicon;
nixos-m1.inputs.nixpkgs.follows = "nixpkgs-unstable";
# ---
# DEPLOYMENT ONLY! secrets
2022-06-10 02:41:37 +00:00
secrets.url = "git+ssh://git@github.com/natsukagami/nix-deploy-secrets";
2021-10-26 18:25:19 +00:00
};
2021-12-01 18:52:13 +00:00
outputs = { self, darwin, nixpkgs, nixpkgs-unstable, home-manager, deploy-rs, sops-nix, nur, ... }@inputs:
2021-10-29 17:31:16 +00:00
let
2022-07-04 19:41:04 +00:00
overlays = import ./overlay.nix inputs;
2023-04-18 11:03:19 +00:00
lib = nixpkgs.lib;
2021-12-09 20:54:26 +00:00
2023-04-18 11:03:19 +00:00
applyOverlays = { ... }: {
nixpkgs.overlays = lib.mkBefore overlays;
};
2022-07-04 19:41:04 +00:00
2023-04-18 11:03:19 +00:00
nixpkgsAsRegistry_ = stable: { lib, ... }: {
imports = [ applyOverlays ];
nix.registry.current-system.flake = self;
2022-07-04 19:41:04 +00:00
nix.registry.nixpkgs.flake = stable;
2021-12-09 20:54:26 +00:00
nix.registry.nixpkgs-unstable.flake = nixpkgs-unstable;
nix.nixPath = [
"nixpkgs=${nixpkgs}"
"nixpkgs-unstable=${nixpkgs-unstable}"
"/nix/var/nix/profiles/per-user/root/channels"
];
2022-07-04 19:41:04 +00:00
# Binary Cache for Haskell.nix
nix.settings.trusted-public-keys = [
2022-07-04 19:41:04 +00:00
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
];
nix.settings.substituters = [
2022-07-04 19:41:04 +00:00
"https://cache.iog.io"
];
};
2023-04-18 11:03:19 +00:00
nixpkgsAsRegistry = nixpkgsAsRegistry_ nixpkgs;
# Common Nix modules
common-nix = stable: { ... }: {
imports = [
(nixpkgsAsRegistry_ stable)
./common.nix
sops-nix.nixosModules.sops
];
};
common-nixos = stable: { ... }: {
imports = [
(common-nix stable)
inputs.secrets.nixosModules.common
];
};
2021-12-09 20:54:26 +00:00
enableOsuStable = { lib, ... }: {
imports = [ inputs.nix-gaming.nixosModules.pipewireLowLatency ];
services.pipewire = {
enable = true;
# alsa is optional
alsa.enable = true;
alsa.support32Bit = true;
# needed for osu
pulse.enable = true;
lowLatency.enable = true;
};
hardware.pulseaudio.enable = lib.mkOverride 0 false;
nix.settings.substituters = [ "https://nix-gaming.cachix.org" ];
nix.settings.trusted-public-keys = [ "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" ];
2021-12-09 20:54:26 +00:00
environment.systemPackages = [ inputs.nix-gaming.packages.x86_64-linux.osu-stable ];
};
2021-10-29 17:31:16 +00:00
in
{
2023-04-18 11:03:19 +00:00
overlays.default = lib.composeManyExtensions overlays;
2021-10-29 17:31:16 +00:00
# MacBook configuration: nix-darwin + home-manager
2022-07-04 19:41:04 +00:00
darwinConfigurations."nki-macbook" = darwin.lib.darwinSystem rec {
2021-10-29 17:31:16 +00:00
system = "aarch64-darwin";
modules = [
2023-04-18 11:03:19 +00:00
(common-nix nixpkgs-unstable)
2021-10-29 17:31:16 +00:00
./darwin/configuration.nix
2023-03-27 12:59:32 +00:00
inputs.home-manager-unstable.darwinModules.home-manager
2021-10-26 18:25:19 +00:00
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
2021-10-27 16:35:53 +00:00
home-manager.users.nki = import ./home/macbook-home.nix;
2021-10-29 17:31:16 +00:00
}
];
};
2021-10-29 17:31:16 +00:00
# Home configuration
2022-12-05 09:59:59 +00:00
nixosConfigurations."nki-home" = nixpkgs.lib.nixosSystem rec {
2021-10-29 17:31:16 +00:00
system = "x86_64-linux";
modules = [
2023-04-18 11:03:19 +00:00
(common-nixos nixpkgs)
2021-10-29 17:31:16 +00:00
./nki-home/configuration.nix
2021-12-09 20:54:26 +00:00
enableOsuStable
2021-12-01 18:52:13 +00:00
home-manager.nixosModules.home-manager
2021-10-29 17:31:16 +00:00
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
2023-03-31 08:26:13 +00:00
home-manager.users.nki = { ... }: {
imports = [
inputs.mpd-mpris.homeManagerModules.default
./home/kagami-pc-home.nix
];
};
2021-10-29 17:31:16 +00:00
}
];
};
2022-04-19 20:46:33 +00:00
# x1c1 configuration
2022-07-04 19:41:04 +00:00
nixosConfigurations."nki-x1c1" = nixpkgs.lib.nixosSystem rec {
2022-04-19 20:46:33 +00:00
system = "x86_64-linux";
modules = [
2023-04-18 11:03:19 +00:00
(common-nixos nixpkgs)
2022-04-19 20:46:33 +00:00
./nki-x1c1/configuration.nix
2022-04-19 21:44:08 +00:00
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.nki = import ./home/nki-x1c1.nix;
}
2022-04-19 20:46:33 +00:00
];
};
2022-10-16 21:55:37 +00:00
# macbook nixos
nixosConfigurations."kagami-air-m1" = nixpkgs-unstable.lib.nixosSystem rec {
2022-10-16 21:55:37 +00:00
system = "aarch64-linux";
modules = [
2023-04-18 11:03:19 +00:00
(common-nixos nixpkgs)
2023-02-25 20:43:29 +00:00
inputs.nixos-m1.nixosModules.apple-silicon-support
2022-10-16 21:55:37 +00:00
./kagami-air-m1/configuration.nix
inputs.home-manager-unstable.nixosModules.home-manager
2022-10-16 21:55:37 +00:00
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.nki = import ./home/macbook-nixos.nix;
}
];
};
# DigitalOcean node
2022-12-05 09:59:59 +00:00
nixosConfigurations."nki-personal-do" = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [
2023-04-18 11:03:19 +00:00
(common-nixos nixpkgs)
./modules/my-tinc
2021-11-03 17:22:27 +00:00
inputs.youmubot.nixosModule.x86_64-linux
./nki-personal-do/configuration.nix
inputs.secrets.nixosModules.x86_64-linux.nki-personal-do
];
};
deploy.nodes."nki-personal-do" = {
hostname = "nki-personal-do";
sshUser = "root";
profiles.system = {
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations."nki-personal-do";
};
};
# This is highly advised, and will prevent many possible mistakes
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
2022-05-31 16:45:33 +00:00
} // (inputs.flake-utils.lib.eachDefaultSystem (system: {
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
}));
2021-10-26 18:25:19 +00:00
}