nixos-config/flake.nix
Sridhar Ratnakumar 015321ff68 fix hm in nixos
2022-04-08 22:25:31 -04:00

143 lines
4.8 KiB
Nix

{
description = "Srid's NixOS configuration";
inputs = {
# To update nixpkgs (and thus NixOS), pick the nixos-unstable rev from
# https://status.nixos.org/
#
# This ensures that we always use the official nix cache.
nixpkgs.url = "github:nixos/nixpkgs/b6966d911da89e5a7301aaef8b4f0a44c77e103c";
darwin.url = "github:lnl7/nix-darwin/master";
darwin.inputs.nixpkgs.follows = "nixpkgs";
nixos-hardware.url = github:NixOS/nixos-hardware/master;
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixos-vscode-server.url = "github:iosmanthus/nixos-vscode-server/add-flake";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
emacs-overlay.url = "github:nix-community/emacs-overlay";
nix-doom-emacs.url = "github:nix-community/nix-doom-emacs";
hercules-ci-agent.url = "github:hercules-ci/hercules-ci-agent/master";
nixos-shell.url = "github:Mic92/nixos-shell";
};
outputs = inputs@{ self, home-manager, nixpkgs, darwin, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
overlayModule =
{
nixpkgs.overlays = [
(inputs.emacs-overlay.overlay)
(inputs.neovim-nightly-overlay.overlay)
];
};
# Configuration common to all of my systems (servers, desktops, laptops)
commonFeatures = [
overlayModule
./features/self-ide.nix
./features/takemessh
./features/caches
./features/current-location.nix
];
homeFeatures = [
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit system inputs; };
home-manager.users.srid = import ./home.nix
{
inherit inputs system pkgs;
};
}
];
mkLinuxSystem = extraModules: nixpkgs.lib.nixosSystem {
inherit system pkgs;
# Arguments to pass to all modules.
specialArgs = { inherit system inputs; };
modules =
commonFeatures ++ homeFeatures ++ extraModules;
};
mkMacosSystem = darwin.lib.darwinSystem;
in
{
nixosConfigurations = {
# My beefy development computer
now = mkLinuxSystem
[
./hosts/hetzner/ax101.nix
./features/server/harden.nix
./features/server/devserver.nix
./features/hercules.nix
];
# This is run in qemu only.
# > nixos-shell --flake github:srid/nixos-config#corsair
corsair = pkgs.lib.makeOverridable nixpkgs.lib.nixosSystem {
inherit system pkgs;
specialArgs = { inherit system inputs; };
modules = [
inputs.nixos-shell.nixosModules.nixos-shell
{
virtualisation = {
memorySize = 8 * 1024;
cores = 2;
diskSize = 20 * 1024;
};
environment.systemPackages = with pkgs; [
protonvpn-cli
aria2
];
nixos-shell.mounts = {
mountHome = false;
mountNixProfile = false;
extraMounts."/Downloads" = {
target = "/home/srid/Downloads";
cache = "none";
};
};
}
];
};
};
darwinConfigurations."air" =
let system = "aarch64-darwin"; in
mkMacosSystem {
inherit system;
specialArgs = {
inherit inputs system;
rosettaPkgs = import nixpkgs { system = "x86_64-darwin"; };
};
modules = [
overlayModule
./hosts/darwin.nix
./features/nix-direnv.nix
./features/caches/oss.nix
home-manager.darwinModules.home-manager
{
# TODO: Refactor-DRY with Linux's home.nix
home-manager.extraSpecialArgs = { inherit system inputs; };
home-manager.users.srid = { pkgs, ... }: {
imports = [
./home/git.nix
./home/tmux.nix
./home/neovim.nix
./home/terminal.nix
# https://github.com/NixOS/nixpkgs/issues/160876
# ./home/starship.nix
];
programs.zsh = {
enable = true;
initExtra = ''
export PATH=$HOME/.nix-profile/bin:/run/current-system/sw/bin/:$PATH
'';
} // (import ./home/shellcommon.nix { inherit pkgs; });
home.stateVersion = "21.11";
};
}
];
};
};
}