2021-11-25 11:55:30 +00:00
|
|
|
{
|
2022-11-25 06:35:11 +00:00
|
|
|
description = "foo-dogsquared's abomination of a NixOS configuration";
|
2022-02-04 12:48:02 +00:00
|
|
|
|
|
|
|
nixConfig = {
|
2022-03-28 00:15:40 +00:00
|
|
|
extra-substituters =
|
|
|
|
"https://nix-community.cachix.org https://foo-dogsquared.cachix.org";
|
|
|
|
extra-trusted-public-keys =
|
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= foo-dogsquared.cachix.org-1:/2fmqn/gLGvCs5EDeQmqwtus02TUmGy0ZlAEXqRE70E=";
|
2022-02-04 12:48:02 +00:00
|
|
|
};
|
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
inputs = {
|
2022-08-27 05:30:04 +00:00
|
|
|
# I know NixOS can be stable but we're going cutting edge, baybee! While
|
|
|
|
# `nixpkgs-unstable` branch could be faster delivering updates, it is
|
|
|
|
# looser when it comes to stability for the entirety of this configuration.
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
2023-01-17 08:46:23 +00:00
|
|
|
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-22.11";
|
2021-12-06 10:12:00 +00:00
|
|
|
|
2022-11-25 06:35:11 +00:00
|
|
|
# We're using these libraries for other functions.
|
2021-12-18 09:41:45 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
2022-07-05 14:28:03 +00:00
|
|
|
# My personal dotfiles.
|
|
|
|
dotfiles.url = "github:foo-dogsquared/dotfiles";
|
|
|
|
dotfiles.flake = false;
|
|
|
|
|
2021-12-11 05:37:27 +00:00
|
|
|
# Managing home configurations.
|
2021-11-25 11:55:30 +00:00
|
|
|
home-manager.url = "github:nix-community/home-manager";
|
|
|
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
2022-07-14 01:10:34 +00:00
|
|
|
home-manager.inputs.utils.follows = "flake-utils";
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2022-01-02 00:48:15 +00:00
|
|
|
# This is what AUR strives to be.
|
|
|
|
nur.url = "github:nix-community/NUR";
|
|
|
|
|
2022-01-12 02:45:06 +00:00
|
|
|
# Running unpatched binaries on NixOS! :O
|
|
|
|
nix-ld.url = "github:Mic92/nix-ld";
|
|
|
|
nix-ld.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2022-02-04 15:36:22 +00:00
|
|
|
# Generate your NixOS systems to various formats!
|
|
|
|
nixos-generators.url = "github:nix-community/nixos-generators";
|
|
|
|
nixos-generators.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2021-12-11 05:37:27 +00:00
|
|
|
# Managing your secrets.
|
2022-07-17 01:36:29 +00:00
|
|
|
sops-nix.url = "github:Mic92/sops-nix";
|
|
|
|
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
# Easy access to development environments.
|
|
|
|
devshell.url = "github:numtide/devshell";
|
2022-07-14 01:10:34 +00:00
|
|
|
devshell.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
devshell.inputs.flake-utils.follows = "flake-utils";
|
2021-12-18 09:41:45 +00:00
|
|
|
|
2022-11-25 06:35:11 +00:00
|
|
|
# We're getting more unstable there should be a black hole at my home right
|
|
|
|
# now. Also, we're seem to be collecting text editors like it is Pokemon.
|
2021-12-06 07:33:03 +00:00
|
|
|
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
|
2023-01-17 08:46:23 +00:00
|
|
|
neovim-nightly-overlay.inputs.nixpkgs.url = "github:nixos/nixpkgs?rev=fad51abd42ca17a60fc1d4cb9382e2d79ae31836";
|
2022-07-09 21:40:56 +00:00
|
|
|
|
2022-01-02 00:40:01 +00:00
|
|
|
emacs-overlay.url = "github:nix-community/emacs-overlay";
|
2022-07-09 21:40:56 +00:00
|
|
|
emacs-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
2022-07-14 01:10:34 +00:00
|
|
|
emacs-overlay.inputs.flake-utils.follows = "flake-utils";
|
2022-01-02 00:40:01 +00:00
|
|
|
|
2022-08-04 13:32:15 +00:00
|
|
|
helix-editor.url = "github:helix-editor/helix";
|
|
|
|
helix-editor.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2022-01-18 12:05:25 +00:00
|
|
|
# Guix in NixOS?!
|
|
|
|
guix-overlay.url = "github:foo-dogsquared/nix-overlay-guix";
|
|
|
|
|
2022-01-12 02:46:25 +00:00
|
|
|
# The more recommended Rust overlay so I'm going with it.
|
2021-12-26 09:33:00 +00:00
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
|
|
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
2022-07-14 01:10:34 +00:00
|
|
|
rust-overlay.inputs.flake-utils.follows = "flake-utils";
|
2022-02-27 02:07:18 +00:00
|
|
|
|
|
|
|
# Generating an entire flavored themes with Nix?
|
|
|
|
nix-colors.url = "github:misterio77/nix-colors";
|
2022-11-13 05:49:54 +00:00
|
|
|
|
|
|
|
# Deploying stuff with Nix. This is becoming a monorepo for everything I
|
|
|
|
# need and I'm liking it.
|
|
|
|
deploy.url = "github:serokell/deploy-rs";
|
|
|
|
deploy.inputs.nixpkgs.follows = "nixpkgs";
|
2021-11-25 11:55:30 +00:00
|
|
|
};
|
|
|
|
|
2022-01-07 03:09:32 +00:00
|
|
|
outputs = inputs@{ self, nixpkgs, ... }:
|
2021-11-25 11:55:30 +00:00
|
|
|
let
|
2022-01-02 14:30:00 +00:00
|
|
|
# The order here is important(?).
|
2021-12-06 07:33:03 +00:00
|
|
|
overlays = [
|
|
|
|
# Put my custom packages to be available.
|
2022-08-13 00:31:09 +00:00
|
|
|
self.overlays.default
|
2022-08-04 13:32:15 +00:00
|
|
|
|
2021-12-06 07:33:03 +00:00
|
|
|
# Neovim nightly!
|
|
|
|
inputs.neovim-nightly-overlay.overlay
|
2021-12-26 09:33:00 +00:00
|
|
|
|
2022-01-02 00:40:01 +00:00
|
|
|
# Emacs unstable version!
|
|
|
|
inputs.emacs-overlay.overlay
|
|
|
|
|
2021-12-26 09:33:00 +00:00
|
|
|
# Rust overlay for them ease of setting up Rust toolchains.
|
2022-07-09 02:42:39 +00:00
|
|
|
inputs.rust-overlay.overlays.default
|
2022-01-02 00:48:15 +00:00
|
|
|
|
|
|
|
# Access to NUR.
|
|
|
|
inputs.nur.overlay
|
2021-12-06 07:33:03 +00:00
|
|
|
];
|
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
defaultSystem = inputs.flake-utils.lib.system.x86_64-linux;
|
2022-11-25 06:35:11 +00:00
|
|
|
|
|
|
|
# Just add systems here and it should add systems to the outputs.
|
2022-08-19 08:53:15 +00:00
|
|
|
systems = with inputs.flake-utils.lib.system; [ defaultSystem ];
|
2022-03-28 00:15:40 +00:00
|
|
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
2021-12-08 04:20:18 +00:00
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
# We're considering this as the variant since we'll export the custom
|
|
|
|
# library as `lib` in the output attribute.
|
2022-07-09 05:46:06 +00:00
|
|
|
lib' = nixpkgs.lib.extend (final: prev:
|
|
|
|
import ./lib { lib = prev; }
|
|
|
|
// import ./lib/private.nix { lib = final; });
|
2022-07-08 22:51:16 +00:00
|
|
|
|
2022-09-25 03:45:44 +00:00
|
|
|
extraArgs = {
|
|
|
|
inherit (inputs) nix-colors dotfiles;
|
|
|
|
inherit inputs self;
|
2022-09-28 11:49:44 +00:00
|
|
|
|
|
|
|
# This is a variable that is used to check whether the module is
|
|
|
|
# exported or not. Useful for configuring parts of the configuration
|
|
|
|
# that is otherwise that cannot be exported for others' use.
|
|
|
|
#
|
|
|
|
# "Fds" stands for foo-dogsquared just because. :p
|
|
|
|
_isInsideFds = true;
|
2022-09-25 03:45:44 +00:00
|
|
|
};
|
2022-08-17 10:43:48 +00:00
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
mkHost = { system ? defaultSystem, extraModules ? [ ] }:
|
|
|
|
(lib'.makeOverridable inputs.nixpkgs.lib.nixosSystem) {
|
|
|
|
# The system of the NixOS system.
|
|
|
|
inherit system;
|
2022-07-09 02:42:16 +00:00
|
|
|
lib = lib';
|
2022-11-17 05:35:19 +00:00
|
|
|
specialArgs = extraArgs;
|
2022-07-08 22:51:16 +00:00
|
|
|
modules =
|
|
|
|
# Append with our custom NixOS modules from the modules folder.
|
|
|
|
(lib'.modulesToList (lib'.filesToAttr ./modules/nixos))
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
# Our own modules.
|
|
|
|
++ extraModules;
|
2022-02-04 12:45:24 +00:00
|
|
|
};
|
|
|
|
|
2023-02-05 08:27:14 +00:00
|
|
|
# The shared configuration for the entire list of hosts for this cluster.
|
|
|
|
# Take note to only set as minimal configuration as possible since we're
|
|
|
|
# also using this with the stable version of nixpkgs.
|
2022-11-17 05:35:19 +00:00
|
|
|
hostSharedConfig = { config, lib, pkgs, ... }: {
|
2022-09-19 02:55:31 +00:00
|
|
|
# Some defaults for evaluating modules.
|
|
|
|
_module.check = true;
|
|
|
|
|
2022-07-09 05:54:05 +00:00
|
|
|
# Only use imports as minimally as possible with the absolute
|
2022-08-27 05:30:04 +00:00
|
|
|
# requirements of a host. On second thought, only on flakes with
|
|
|
|
# optional NixOS modules.
|
2022-07-09 05:54:05 +00:00
|
|
|
imports = [
|
|
|
|
inputs.home-manager.nixosModules.home-manager
|
2022-07-13 11:10:15 +00:00
|
|
|
inputs.nix-ld.nixosModules.nix-ld
|
2022-07-14 00:19:23 +00:00
|
|
|
inputs.nur.nixosModules.nur
|
2022-07-17 01:36:29 +00:00
|
|
|
inputs.sops-nix.nixosModules.sops
|
2022-08-27 05:30:04 +00:00
|
|
|
inputs.guix-overlay.nixosModules.guix
|
2022-07-09 05:54:05 +00:00
|
|
|
];
|
|
|
|
|
2022-10-27 07:13:30 +00:00
|
|
|
# BOOOOOOOOOOOOO! Somebody give me a tomato!
|
|
|
|
services.xserver.excludePackages = with pkgs; [ xterm ];
|
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
# I want to capture the usual flakes to its exact version so we're
|
|
|
|
# making them available to our system. This will also prevent the
|
|
|
|
# annoying downloads since it always get the latest revision.
|
2022-08-07 02:40:19 +00:00
|
|
|
nix.registry =
|
2022-09-01 15:21:26 +00:00
|
|
|
lib.mapAttrs'
|
2022-08-10 04:24:09 +00:00
|
|
|
(name: flake:
|
|
|
|
let
|
|
|
|
name' = if (name == "self") then "config" else name;
|
|
|
|
in
|
2022-09-01 15:21:26 +00:00
|
|
|
lib.nameValuePair name' { inherit flake; })
|
2022-08-10 04:24:09 +00:00
|
|
|
inputs;
|
2022-08-07 02:40:19 +00:00
|
|
|
|
|
|
|
# Set several paths for the traditional channels.
|
|
|
|
nix.nixPath =
|
2022-09-01 15:21:26 +00:00
|
|
|
lib.mapAttrsToList
|
2022-08-10 04:24:09 +00:00
|
|
|
(name: source:
|
|
|
|
let
|
|
|
|
name' = if (name == "self") then "config" else name;
|
|
|
|
in
|
|
|
|
"${name'}=${source}")
|
|
|
|
inputs
|
2022-08-07 02:40:19 +00:00
|
|
|
++ [
|
|
|
|
"/nix/var/nix/profiles/per-user/root/channels"
|
|
|
|
];
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
nix.settings = {
|
2022-08-10 04:24:09 +00:00
|
|
|
# Set several binary caches.
|
2022-07-08 22:51:16 +00:00
|
|
|
substituters = [
|
|
|
|
"https://nix-community.cachix.org"
|
|
|
|
"https://foo-dogsquared.cachix.org"
|
2022-08-04 13:32:15 +00:00
|
|
|
"https://helix.cachix.org"
|
2022-07-05 23:38:05 +00:00
|
|
|
];
|
2022-07-08 22:51:16 +00:00
|
|
|
trusted-public-keys = [
|
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
|
|
"foo-dogsquared.cachix.org-1:/2fmqn/gLGvCs5EDeQmqwtus02TUmGy0ZlAEXqRE70E="
|
2022-08-04 13:32:15 +00:00
|
|
|
"helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="
|
2022-04-30 12:30:22 +00:00
|
|
|
];
|
2022-08-10 04:24:09 +00:00
|
|
|
|
|
|
|
# Sane config for the package manager.
|
|
|
|
# TODO: Remove this after nix-command and flakes has been considered stable.
|
|
|
|
#
|
|
|
|
# Since we're using flakes to make this possible, we need it. Plus, the
|
|
|
|
# UX of Nix CLI is becoming closer to Guix's which is a nice bonus.
|
|
|
|
experimental-features = [ "nix-command" "flakes" ];
|
2022-09-01 15:21:26 +00:00
|
|
|
auto-optimise-store = lib.mkDefault true;
|
2022-04-16 16:15:02 +00:00
|
|
|
};
|
2022-07-08 22:51:16 +00:00
|
|
|
|
|
|
|
# Stallman-senpai will be disappointed.
|
2022-11-25 06:35:11 +00:00
|
|
|
nixpkgs.config.allowUnfree = true;
|
2022-07-08 22:51:16 +00:00
|
|
|
|
|
|
|
# Extend nixpkgs with our overlays except for the NixOS-focused modules
|
|
|
|
# here.
|
2022-11-30 00:34:07 +00:00
|
|
|
nixpkgs.overlays = overlays;
|
2022-07-08 22:51:16 +00:00
|
|
|
|
|
|
|
# Please clean your temporary crap.
|
2022-09-19 02:55:31 +00:00
|
|
|
boot.cleanTmpDir = lib.mkDefault true;
|
2022-07-08 22:51:16 +00:00
|
|
|
|
|
|
|
# We live in a Unicode world and dominantly English in technical fields so we'll
|
|
|
|
# have to go with it.
|
2022-09-01 15:21:26 +00:00
|
|
|
i18n.defaultLocale = lib.mkDefault "en_US.UTF-8";
|
2022-07-08 22:51:16 +00:00
|
|
|
|
2022-07-08 23:08:27 +00:00
|
|
|
# The global configuration for the home-manager module.
|
2022-09-19 02:55:31 +00:00
|
|
|
home-manager.useUserPackages = lib.mkDefault true;
|
|
|
|
home-manager.useGlobalPkgs = lib.mkDefault true;
|
2022-07-08 23:08:27 +00:00
|
|
|
home-manager.sharedModules =
|
2022-09-01 15:21:26 +00:00
|
|
|
lib.modulesToList (lib.filesToAttr ./modules/home-manager)
|
2022-09-29 03:35:00 +00:00
|
|
|
++ [ userSharedConfig ];
|
2022-08-19 08:53:15 +00:00
|
|
|
home-manager.extraSpecialArgs = extraArgs;
|
2022-07-09 05:56:36 +00:00
|
|
|
|
2022-07-17 01:36:29 +00:00
|
|
|
# Enabling some things for sops.
|
2022-09-19 02:55:31 +00:00
|
|
|
programs.gnupg.agent = lib.mkDefault {
|
2022-07-09 05:56:36 +00:00
|
|
|
enable = true;
|
|
|
|
enableSSHSupport = true;
|
|
|
|
};
|
2022-09-19 02:55:31 +00:00
|
|
|
services.sshd.enable = lib.mkDefault true;
|
|
|
|
services.openssh.enable = lib.mkDefault true;
|
2022-11-05 01:25:24 +00:00
|
|
|
|
2022-11-06 09:38:51 +00:00
|
|
|
# We're setting Guix service package with the flake-provided package.
|
|
|
|
# This is to prevent problems setting with overlays as much as I like
|
|
|
|
# using them.
|
2022-11-17 05:35:19 +00:00
|
|
|
services.guix.package = inputs.guix-overlay.packages.${config.nixpkgs.system}.guix;
|
2021-11-25 11:55:30 +00:00
|
|
|
};
|
2021-11-29 05:30:57 +00:00
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
mkUser = { system ? defaultSystem, extraModules ? [ ] }:
|
|
|
|
inputs.home-manager.lib.homeManagerConfiguration {
|
2022-08-19 08:53:15 +00:00
|
|
|
extraSpecialArgs = extraArgs;
|
2022-07-09 02:42:16 +00:00
|
|
|
lib = lib';
|
2022-09-19 02:55:31 +00:00
|
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
2022-07-08 22:51:16 +00:00
|
|
|
modules =
|
|
|
|
# Importing our custom home-manager modules.
|
|
|
|
(lib'.modulesToList (lib'.filesToAttr ./modules/home-manager))
|
2022-03-01 15:05:20 +00:00
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
# Plus our own.
|
|
|
|
++ extraModules;
|
2022-03-01 15:05:20 +00:00
|
|
|
};
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2022-08-06 05:58:24 +00:00
|
|
|
# The default config for our home-manager configurations. This is also to
|
|
|
|
# be used for sharing modules among home-manager users from NixOS
|
|
|
|
# configurations with `nixpkgs.useGlobalPkgs` set to `true` so avoid
|
|
|
|
# setting nixpkgs-related options here.
|
2022-09-29 03:35:00 +00:00
|
|
|
userSharedConfig = { pkgs, config, ... }: {
|
2022-08-06 05:58:24 +00:00
|
|
|
# Hardcoding this is not really great especially if you consider using
|
|
|
|
# other locales but its default values are already hardcoded so what
|
|
|
|
# the hell. For other users, they would have to do set these manually.
|
2022-08-10 04:24:09 +00:00
|
|
|
xdg.userDirs =
|
|
|
|
let
|
2022-09-19 02:55:31 +00:00
|
|
|
# The home directory-related options should be already taken care
|
|
|
|
# of at this point. It is an ABSOLUTE MUST that it is set properly
|
|
|
|
# since other parts of the home-manager config relies on it being
|
|
|
|
# set properly.
|
|
|
|
#
|
2022-11-25 06:35:11 +00:00
|
|
|
# Here are some of the common cases for setting the home directory
|
|
|
|
# options.
|
2022-09-19 02:55:31 +00:00
|
|
|
#
|
2022-11-25 06:35:11 +00:00
|
|
|
# * For exporting home-manager configurations, this is done in this
|
|
|
|
# flake definition.
|
|
|
|
# * For NixOS configs, this is done automatically by the
|
|
|
|
# home-manager NixOS module.
|
2022-09-19 02:55:31 +00:00
|
|
|
# * Otherwise, you'll have to manually set them.
|
2022-08-10 04:24:09 +00:00
|
|
|
appendToHomeDir = path: "${config.home.homeDirectory}/${path}";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
desktop = appendToHomeDir "Desktop";
|
|
|
|
documents = appendToHomeDir "Documents";
|
|
|
|
download = appendToHomeDir "Downloads";
|
|
|
|
music = appendToHomeDir "Music";
|
|
|
|
pictures = appendToHomeDir "Pictures";
|
|
|
|
publicShare = appendToHomeDir "Public";
|
|
|
|
templates = appendToHomeDir "Templates";
|
|
|
|
videos = appendToHomeDir "Videos";
|
|
|
|
};
|
2021-12-11 05:37:27 +00:00
|
|
|
|
2022-09-25 03:46:14 +00:00
|
|
|
programs.home-manager.enable = true;
|
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
manual = {
|
|
|
|
html.enable = true;
|
|
|
|
json.enable = true;
|
|
|
|
manpages.enable = true;
|
|
|
|
};
|
2021-12-06 07:33:03 +00:00
|
|
|
};
|
2022-11-25 06:27:11 +00:00
|
|
|
|
|
|
|
# A wrapper around the nixos-generators `nixosGenerate` function.
|
|
|
|
mkImage = { system ? null, pkgs ? null, extraModules ? [ ], extraArgs ? { }, format ? "iso" }:
|
|
|
|
inputs.nixos-generators.nixosGenerate {
|
|
|
|
inherit pkgs system format;
|
|
|
|
lib = lib';
|
|
|
|
specialArgs = extraArgs;
|
|
|
|
modules =
|
|
|
|
# Import all of the NixOS modules.
|
|
|
|
(lib'.modulesToList (lib'.filesToAttr ./modules/nixos))
|
|
|
|
|
|
|
|
# Our own modules.
|
|
|
|
++ extraModules;
|
|
|
|
};
|
2022-11-30 00:34:52 +00:00
|
|
|
|
|
|
|
# A set of images with their metadata that is usually built for usual
|
|
|
|
# purposes. The format used here is whatever formats nixos-generators
|
|
|
|
# support.
|
|
|
|
images = {
|
|
|
|
bootstrap.format = "install-iso";
|
|
|
|
graphical-installer.format = "install-iso";
|
|
|
|
void.format = "vm";
|
|
|
|
};
|
2022-08-06 06:00:04 +00:00
|
|
|
in
|
|
|
|
{
|
2021-12-18 09:41:45 +00:00
|
|
|
# Exposes only my library with the custom functions to make it easier to
|
2022-07-09 06:04:17 +00:00
|
|
|
# include in other flakes for whatever reason may be.
|
2022-01-07 03:08:50 +00:00
|
|
|
lib = import ./lib { lib = nixpkgs.lib; };
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
# A list of NixOS configurations from the `./hosts` folder. It also has
|
|
|
|
# some sensible default configurations.
|
2022-08-06 06:00:04 +00:00
|
|
|
nixosConfigurations = lib'.mapAttrsRecursive
|
|
|
|
(host: path:
|
|
|
|
let
|
2022-11-25 13:28:11 +00:00
|
|
|
host' = lib'.last host;
|
2022-08-06 06:00:04 +00:00
|
|
|
extraModules = [
|
2022-09-01 15:21:26 +00:00
|
|
|
({ lib, ... }: {
|
2022-11-25 13:28:11 +00:00
|
|
|
# We're very lax with setting the default since there's a lot
|
|
|
|
# of modules that may set this especially with image media
|
|
|
|
# modules.
|
2023-01-18 07:44:11 +00:00
|
|
|
networking.hostName = host';
|
2022-09-01 15:21:26 +00:00
|
|
|
})
|
2022-12-01 00:20:18 +00:00
|
|
|
(lib'.optionalAttrs (lib'.hasAttr host' images)
|
2023-01-07 08:06:34 +00:00
|
|
|
(
|
|
|
|
let
|
|
|
|
imageFormat = images.${host'}.format;
|
|
|
|
in
|
|
|
|
inputs.nixos-generators.nixosModules.${imageFormat}
|
|
|
|
))
|
2022-09-29 03:35:00 +00:00
|
|
|
hostSharedConfig
|
2022-08-06 06:00:04 +00:00
|
|
|
path
|
2022-11-30 00:34:52 +00:00
|
|
|
];
|
2022-08-06 06:00:04 +00:00
|
|
|
in
|
|
|
|
mkHost { inherit extraModules; })
|
|
|
|
(lib'.filesToAttr ./hosts);
|
2021-11-25 11:55:30 +00:00
|
|
|
|
|
|
|
# We're going to make our custom modules available for our flake. Whether
|
|
|
|
# or not this is a good thing is debatable, I just want to test it.
|
2022-07-14 00:17:02 +00:00
|
|
|
nixosModules = lib'.importModules (lib'.filesToAttr ./modules/nixos);
|
2021-12-06 06:55:00 +00:00
|
|
|
|
2021-12-06 09:55:40 +00:00
|
|
|
# I can now install home-manager users in non-NixOS systems.
|
2022-03-28 00:15:40 +00:00
|
|
|
# NICE!
|
2022-08-06 05:58:24 +00:00
|
|
|
homeManagerConfigurations = lib'.mapAttrs
|
|
|
|
(_: path:
|
|
|
|
let
|
|
|
|
extraModules = [
|
|
|
|
({ pkgs, config, ... }: {
|
2022-11-25 06:35:11 +00:00
|
|
|
# To be able to use the most of our config as possible, we want
|
|
|
|
# both to use the same overlays.
|
2022-08-06 05:58:24 +00:00
|
|
|
nixpkgs.overlays = overlays;
|
|
|
|
|
2022-09-29 03:35:00 +00:00
|
|
|
# Stallman-senpai will be disappointed. :/
|
2022-08-06 05:58:24 +00:00
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
|
|
|
|
# Setting the homely options.
|
|
|
|
home.username = builtins.baseNameOf path;
|
|
|
|
home.homeDirectory = "/home/${config.home.username}";
|
|
|
|
})
|
2022-09-29 03:35:00 +00:00
|
|
|
userSharedConfig
|
2022-08-06 05:58:24 +00:00
|
|
|
path
|
|
|
|
];
|
|
|
|
in
|
|
|
|
mkUser { inherit extraModules; })
|
2022-04-15 12:49:59 +00:00
|
|
|
(lib'.filesToAttr ./users/home-manager);
|
2021-11-29 09:56:24 +00:00
|
|
|
|
2021-12-06 09:55:40 +00:00
|
|
|
# Extending home-manager with my custom modules, if anyone cares.
|
2022-08-06 05:58:24 +00:00
|
|
|
homeManagerModules =
|
|
|
|
lib'.importModules (lib'.filesToAttr ./modules/home-manager);
|
2021-11-29 05:30:57 +00:00
|
|
|
|
2022-07-14 00:18:34 +00:00
|
|
|
# In case somebody wants to use my stuff to be included in nixpkgs.
|
|
|
|
overlays.default = final: prev: import ./pkgs { pkgs = prev; };
|
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
# My custom packages, available in here as well. Though, I mainly support
|
|
|
|
# "x86_64-linux". I just want to try out supporting other systems.
|
2023-01-07 08:06:34 +00:00
|
|
|
packages = forAllSystems (system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
|
|
|
in
|
2022-11-25 06:27:11 +00:00
|
|
|
inputs.flake-utils.lib.flattenTree (import ./pkgs { inherit pkgs; })
|
|
|
|
// lib'.mapAttrs'
|
2023-01-07 08:06:34 +00:00
|
|
|
(name: value:
|
|
|
|
lib'.nameValuePair "${name}-${value.format}" (mkImage {
|
|
|
|
inherit system pkgs extraArgs;
|
|
|
|
inherit (value) format;
|
|
|
|
extraModules = [
|
|
|
|
({ lib, ... }: {
|
|
|
|
networking.hostName = lib.mkOverride 2000 name;
|
|
|
|
})
|
|
|
|
hostSharedConfig
|
|
|
|
./hosts/${name}
|
|
|
|
];
|
|
|
|
}))
|
|
|
|
images);
|
2021-12-13 07:32:58 +00:00
|
|
|
|
|
|
|
# My several development shells for usual type of projects. This is much
|
|
|
|
# more preferable than installing all of the packages at the system
|
|
|
|
# configuration (or even home environment).
|
2021-12-18 09:41:45 +00:00
|
|
|
devShells = forAllSystems (system:
|
2022-03-28 00:15:40 +00:00
|
|
|
let pkgs = import nixpkgs { inherit system overlays; };
|
|
|
|
in {
|
|
|
|
default = import ./shell.nix { inherit pkgs; };
|
|
|
|
} // (import ./shells { inherit pkgs; }));
|
2022-01-25 01:28:10 +00:00
|
|
|
|
|
|
|
# Cookiecutter templates for your mama.
|
|
|
|
templates = {
|
2022-03-28 00:15:40 +00:00
|
|
|
default = self.templates.basic-devshell;
|
2022-01-25 01:28:10 +00:00
|
|
|
basic-devshell = {
|
|
|
|
path = ./templates/basic-devshell;
|
|
|
|
description = "Basic development shell template";
|
|
|
|
};
|
2022-09-01 02:01:15 +00:00
|
|
|
basic-overlay-flake = {
|
|
|
|
path = ./templates/basic-overlay-flake;
|
|
|
|
description = "Basic overlay as a flake";
|
|
|
|
};
|
2022-01-25 01:28:10 +00:00
|
|
|
};
|
2022-08-06 06:57:45 +00:00
|
|
|
|
|
|
|
# No amount of formatters will make this codebase nicer but it sure does
|
|
|
|
# feel like it does.
|
|
|
|
formatter =
|
2022-11-19 03:00:53 +00:00
|
|
|
forAllSystems (system: nixpkgs.legacyPackages.${system}.treefmt);
|
2022-11-13 05:49:54 +00:00
|
|
|
|
2022-11-30 00:40:49 +00:00
|
|
|
# nixops-lite (that is much more powerful than nixops itself)... in
|
|
|
|
# here!?! We got it all, son!
|
2022-11-13 05:49:54 +00:00
|
|
|
#
|
|
|
|
# Take note for automatically imported nodes, various options should be
|
|
|
|
# overridden in the deploy utility considering that most have only
|
|
|
|
# certain values and likely not work if run with the intended value.
|
2022-11-30 00:40:49 +00:00
|
|
|
#
|
|
|
|
# Also, don't forget to always clean your shell history when overriding
|
|
|
|
# sensitive info such as the hostname and such. A helpful tip would be
|
|
|
|
# ignoring the shell entry by simply prefixing it with a space which most
|
|
|
|
# command-line shells have support for (e.g., Bash, zsh, fish).
|
2023-01-07 08:06:34 +00:00
|
|
|
deploy.nodes =
|
|
|
|
let
|
|
|
|
nixosConfigurations = lib'.mapAttrs'
|
|
|
|
(name: value:
|
|
|
|
lib'.nameValuePair "nixos-${name}" {
|
|
|
|
hostname = name;
|
|
|
|
fastConnection = true;
|
|
|
|
profiles.system = {
|
|
|
|
sshUser = "admin";
|
|
|
|
user = "root";
|
|
|
|
path = inputs.deploy.lib.${defaultSystem}.activate.nixos value;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
self.nixosConfigurations;
|
|
|
|
homeManagerConfigurations = lib'.mapAttrs'
|
|
|
|
(name: value:
|
|
|
|
lib'.nameValuePair "home-manager-${name}" {
|
|
|
|
hostname = name;
|
|
|
|
fastConnection = true;
|
|
|
|
profiles.home = {
|
|
|
|
sshUser = name;
|
|
|
|
path = inputs.deploy.lib.${defaultSystem}.activate.home-manager value;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
self.homeManagerConfigurations;
|
|
|
|
in
|
|
|
|
nixosConfigurations // homeManagerConfigurations;
|
2022-11-13 05:49:54 +00:00
|
|
|
|
|
|
|
# How to make yourself slightly saner than before. So far the main checks
|
|
|
|
# are for deploy nodes.
|
|
|
|
checks = lib'.mapAttrs
|
|
|
|
(system: deployLib: deployLib.deployChecks self.deploy)
|
|
|
|
inputs.deploy.lib;
|
2022-11-21 12:33:58 +00:00
|
|
|
|
|
|
|
# I'm cut off from the rest of my setup with no Hydra instance yet but
|
|
|
|
# I'm sure it will grow some of them as long as you didn't put it under a
|
|
|
|
# rock.
|
2022-12-04 06:09:08 +00:00
|
|
|
hydraJobs.build-packages = forAllSystems (system: self.packages.${system});
|
2022-01-25 01:32:17 +00:00
|
|
|
};
|
2021-11-25 11:55:30 +00:00
|
|
|
}
|