nixos-config/flake.nix

242 lines
8.6 KiB
Nix
Raw Normal View History

{
description = "foo-dogsquared's NixOS config as a flake";
2022-02-04 12:48:02 +00:00
nixConfig = {
extra-experimental-features = "nix-command flakes";
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
};
inputs = {
# I know NixOS can be stable but we're going cutting edge, baybee!
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
2021-12-06 10:12:00 +00:00
2021-12-18 09:41:45 +00:00
# We're using this library for other functions, mainly testing.
flake-utils.url = "github:numtide/flake-utils";
# Managing home configurations.
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# This is what AUR strives to be.
nur.url = "github:nix-community/NUR";
nur.inputs.nixpkgs.follows = "nixpkgs";
# Running unpatched binaries on NixOS! :O
nix-ld.url = "github:Mic92/nix-ld";
nix-ld.inputs.nixpkgs.follows = "nixpkgs";
nix-alien.url = "github:thiagokokada/nix-alien";
nix-alien.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";
# Managing your secrets.
agenix.url = "github:ryantm/agenix";
agenix.inputs.nixpkgs.follows = "nixpkgs";
2021-12-18 09:41:45 +00:00
# Easy access to development environments.
devshell.url = "github:numtide/devshell";
# We're getting more unstable there should be a black hole at my home right now.
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
2022-01-02 00:40:01 +00:00
emacs-overlay.url = "github:nix-community/emacs-overlay";
# Guix in NixOS?!
guix-overlay.url = "github:foo-dogsquared/nix-overlay-guix";
guix-overlay.inputs.nixpkgs.follows = "nixpkgs";
# 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";
flake.lock: update Flake lock file updates: • Updated input 'agenix': 'github:ryantm/agenix/a17d1f30550260f8b45764ddbd0391f4b1ed714a' (2022-02-02) → 'github:ryantm/agenix/b4ab630f195cb15f833cb285de232b1a22d1ea0a' (2022-02-22) • Updated input 'emacs-overlay': 'github:nix-community/emacs-overlay/6ecfaeb355326456e7b331d1527105adab360adc' (2022-02-18) → 'github:nix-community/emacs-overlay/f7eca8816dd24bed25f7c6a49cf4185d3725642d' (2022-02-27) • Updated input 'home-manager': 'github:nix-community/home-manager/4f4165a8b9108818ab0193bbd1a252106870b2a2' (2022-02-17) → 'github:nix-community/home-manager/2499b916921adde8a694117bc007efdde8bbd918' (2022-02-27) • Updated input 'neovim-nightly-overlay': 'github:nix-community/neovim-nightly-overlay/7ab23810d3844251fef656d7acc4bfbb2c4584bd' (2022-02-18) → 'github:nix-community/neovim-nightly-overlay/9a5300fb01ef2eb5013f932913e8e7d5d96e4e9d' (2022-02-26) • Updated input 'neovim-nightly-overlay/neovim-flake': 'github:neovim/neovim/faeff49cbfd190afba67e221412b7132b7ad8360?dir=contrib' (2022-02-18) → 'github:neovim/neovim/005a7aa1670841dfdffb7559161a7d37d6c14bc4?dir=contrib' (2022-02-25) • Updated input 'neovim-nightly-overlay/nixpkgs': 'github:nixos/nixpkgs/48d63e924a2666baf37f4f14a18f19347fbd54a2' (2022-02-10) → 'github:nixos/nixpkgs/7f9b6e2babf232412682c09e57ed666d8f84ac2d' (2022-02-21) • Updated input 'nixos-generators': 'github:nix-community/nixos-generators/296067b9c7a172d294831dec89d86847f30a7cfc' (2021-12-26) → 'github:nix-community/nixos-generators/05773c5d1584cebd5eda41675c3456dcabdef42a' (2022-02-25) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/19574af0af3ffaf7c9e359744ed32556f34536bd' (2022-02-16) → 'github:NixOS/nixpkgs/7dda625e7f63445ff61bcf11618999d2c97d5865' (2022-02-23) • Updated input 'nur': 'github:nix-community/NUR/8d98d367039695d78ef5cf89da6e577886de81c1' (2022-02-18) → 'github:nix-community/NUR/1dfd799af1c96ce96e7db9c4f97d8a9fc4f0e30d' (2022-02-27) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/9ce263da4310d02bd16f18f4db1c617265939a3e' (2022-02-19) → 'github:oxalica/rust-overlay/7f273929e83a196f96a0dbee9ea565952e340bd6' (2022-02-26)
2022-02-27 02:07:18 +00:00
# Generating an entire flavored themes with Nix?
nix-colors.url = "github:misterio77/nix-colors";
};
2022-01-07 03:09:32 +00:00
outputs = inputs@{ self, nixpkgs, ... }:
let
2022-01-02 14:30:00 +00:00
# The order here is important(?).
overlays = [
# Put my custom packages to be available.
(self: super: import ./pkgs { pkgs = super; })
# 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.
inputs.rust-overlay.overlay
# Access to NUR.
inputs.nur.overlay
];
systems = with inputs.flake-utils.lib.system; [ x86_64-linux ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
2022-04-15 12:49:59 +00:00
lib' = nixpkgs.lib.extend (final: prev:
(import ./lib { lib = prev; }) // {
flakeUtils = (import ./lib/flake-utils.nix {
inherit inputs;
lib = final;
});
});
# The default configuration for our NixOS systems.
hostDefaultConfig = let system = "x86_64-linux";
in {
inherit system;
2022-02-05 10:58:42 +00:00
# Pass these things to our modules.
specialArgs = {
inherit system inputs self;
lib = nixpkgs.lib.extend (final: prev: import ./lib { lib = prev; });
selfPath = ./.;
};
config = {
# 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.
nix.registry = {
# I'm narcissistic so I want my config to be one of the flakes in the registry.
config.flake = self;
# All of the important flakes will be included.
nixpkgs.flake = nixpkgs;
home-manager.flake = inputs.home-manager;
agenix.flake = inputs.agenix;
nur.flake = inputs.nur;
guix-overlay.flake = inputs.guix-overlay;
nixos-generators.flake = inputs.nixos-generators;
};
# We may as well live on the BLEEDING EDGE!
nix.package = nixpkgs.legacyPackages.${system}.nixUnstable;
# Set several binary caches.
nix.settings = {
substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
"https://foo-dogsquared.cachix.org"
];
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"foo-dogsquared.cachix.org-1:/2fmqn/gLGvCs5EDeQmqwtus02TUmGy0ZlAEXqRE70E="
];
};
# Stallman-senpai will be disappointed.
nixpkgs.config.allowUnfree = true;
# Extend nixpkgs with our overlays except for the NixOS-focused modules
# here.
nixpkgs.overlays = overlays
++ [ inputs.nix-alien.overlay inputs.guix-overlay.overlays.default ];
# Please clean your temporary crap.
boot.cleanTmpDir = true;
# We live in a Unicode world and dominantly English in technical fields so we'll
# have to go with it.
i18n.defaultLocale = "en_US.UTF-8";
# 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.
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
};
};
# The default config for our home-manager configurations.
userDefaultConfig = let system = "x86_64-linux";
in {
inherit system;
extraSpecialArgs = {
inherit system self;
};
2022-01-02 14:30:00 +00:00
extraModules = [{
# To be able to use the most of our config as possible, we want both to
# use the same overlays.
nixpkgs.overlays = overlays;
2022-01-02 14:30:00 +00:00
# Stallman-senpai will be disappointed. :(
nixpkgs.config.allowUnfree = true;
2022-01-02 14:30:00 +00:00
# Let home-manager to manage itself.
programs.home-manager.enable = true;
2022-01-25 01:32:17 +00:00
manual = {
html.enable = true;
json.enable = true;
manpages.enable = true;
};
2022-01-02 14:30:00 +00:00
}];
};
2022-02-02 04:25:03 +00:00
in {
2021-12-18 09:41:45 +00:00
# Exposes only my library with the custom functions to make it easier to
# include in other flakes.
lib = import ./lib { lib = nixpkgs.lib; };
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-04-15 12:49:59 +00:00
nixosConfigurations = lib'.mapAttrsRecursive
(host: path: lib'.flakeUtils.mkHost path hostDefaultConfig)
(lib'.filesToAttr ./hosts);
# 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-04-15 12:49:59 +00:00
nixosModules = lib'.mapAttrsRecursive (_: path: import path)
(lib'.filesToAttr ./modules/nixos);
2021-12-06 09:55:40 +00:00
# I can now install home-manager users in non-NixOS systems.
# NICE!
2022-04-15 12:49:59 +00:00
homeManagerConfigurations = lib'.mapAttrs
(_: path: lib'.flakeUtils.mkUser path userDefaultConfig)
(lib'.filesToAttr ./users/home-manager);
2021-12-06 09:55:40 +00:00
# Extending home-manager with my custom modules, if anyone cares.
2022-04-15 12:49:59 +00:00
homeManagerModules = lib'.mapAttrsRecursive (_: path: import path)
(lib'.filesToAttr ./modules/home-manager);
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.
2022-01-02 14:30:00 +00:00
packages = forAllSystems (system:
2022-02-02 04:25:03 +00:00
inputs.flake-utils.lib.flattenTree (import ./pkgs {
pkgs = import nixpkgs { inherit system overlays; };
}));
# 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:
let pkgs = import nixpkgs { inherit system overlays; };
in {
default = import ./shell.nix { inherit pkgs; };
} // (import ./shells { inherit pkgs; }));
# Cookiecutter templates for your mama.
templates = {
default = self.templates.basic-devshell;
basic-devshell = {
path = ./templates/basic-devshell;
description = "Basic development shell template";
};
};
2022-01-25 01:32:17 +00:00
};
}