Initial work on creating sensible templates

Available templates include the following:
- system: flake based system similar to the default when starting
  nix.
- darwin: flake based darwin system with ajusted nixpkgs and modules to better suit it.
- home-manager: flake and home manager for non darwin systems.

Co-Authored-by: isabelroses <isabel@isabelroses.com>
Co-Authored-by: Skyler Grey <minion@clicks.codes>
Co-Authored-by: Sigmanificient <edhyjox@gmail.com>
Co-Authored-by: AxelSilverdew <7677954+AxelSilverdew@users.noreply.github.com>
This commit is contained in:
Samuel Shuert 2024-05-01 16:46:28 -04:00
commit 3f3ac4306b
Signed by: coded
GPG key ID: 00E944BFBE99ADB5
14 changed files with 547 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.direnv/

24
darwin/core.nix Normal file
View file

@ -0,0 +1,24 @@
{
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
nix.settings = {
# We need this to be able to use the nix-command and flakes features.
# these are essential to use this system configuration as a flake.
experimental-features = [
"nix-command"
"flakes"
];
# this allows the system builder to use substitutes
builders-use-substitutes = true;
# we want these beacuse we don't have to build every package from source
substituters = [ "https://nix-community.cachix.org" ];
trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ];
# We also want to add our user, in this case "axel" to the trusted users
# this is important so that we can use the substituters with no issues
trusted-users = [ "axel" ];
};
}

79
darwin/flake.nix Normal file
View file

@ -0,0 +1,79 @@
{
description = "A simple darwin flake using Aux and home-manager";
inputs = {
# nixpkgs is the input that we use for this flake the end section `nixpkgs-unstable` refers to the branch
# of nixpkgs that we want to use. This can be changed to any branch or commit hash.
nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";
# The `follows` keyword in inputs is used for inheritance.
# we do this in order to prevent duplication of the nixpkgs input, and potential
# issues with diffrent versions of given packages.
# However, it should be noted that this can lead to having to rebuild packages from source.
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
nixpkgs,
darwin,
home-manager,
...
}:
# we can use the `let` and `in` syntax to define variables
# and use them in the rest of the expression
let
# this can be either aarch64-darwin or x86_64-darwin
# if your using a M1 or later your going to need to use aarch64-darwin
# otherwise you can use x86_64-darwin
system = builtins.abort "You need to fill in your system";
# here we define our username and hostname to reuse them later
username = builtins.abort "You need to fill in your username"; # Set this variable equal to your username
hostname = builtins.abort "You need to fill in your hostname"; # Set this variable equal to your hostname
# the specialArgs are used to pass the inputs to the system configuration and home-manager configuration
specialArgs = {
inherit inputs username hostname;
};
in
{
# here the hostname is being set to "reservoir" but you can change that to your needs
# it is important that you use darwin.lib.darwinSystem as this is the builder that allow
# for the configuration of the darwin system
darwinConfigurations.${hostname} = darwin.lib.darwinSystem {
# The specialArgs are used to pass the inputs to the system configuration
inherit specialArgs;
modules = [
./homebrew.nix
./users.nix
# The home-manager module is used to configure home-manager
# to read more about this please see ../home-manager
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# extraSpecialArgs is used to pass the inputs to the home-manager configuration
home-manager.extraSpecialArgs = specialArgs;
# Here we have assume that the use is called "axel" but you can change that to your needs
home-manager.users.${username} = import ./home.nix;
}
];
};
};
}

23
darwin/home.nix Normal file
View file

@ -0,0 +1,23 @@
{ username, ... }:
{
# Home Manager needs a bit of information about you and the
# paths it should manage.
home = {
# rember we set this in our flake.nix file
username = username;
homeDirectory = "/Users/${username}";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
stateVersion = "23.11";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

53
darwin/homebrew.nix Normal file
View file

@ -0,0 +1,53 @@
{
config = {
environment = {
# You can configure your usual shell environment for homebrew here.
variables = {
HOMEBREW_NO_ANALYTICS = "1";
HOMEBREW_NO_INSECURE_REDIRECT = "1";
HOMEBREW_NO_EMOJI = "1";
HOMEBREW_NO_ENV_HINTS = "0";
};
# This is included so that the homebrew packages are available in the PATH.
systemPath = [ config.homebrew.brewPrefix ];
};
# homebrew need to be installed manually, see https://brew.sh
# The apps installed by homebrew are not managed by nix, and not reproducible!
homebrew = {
enable = true;
caskArgs.require_sha = true;
onActivation = {
autoUpdate = true;
upgrade = true;
# 'zap': uninstalls all formulae(and related files) not listed here.
cleanup = "zap";
};
# Applications to install from Mac App Store using mas.
# You need to install all these Apps manually first so that your apple account have records for them.
# otherwise Apple Store will refuse to install them.
# For details, see https://github.com/mas-cli/mas
masApps = { };
taps = [ "homebrew/bundle" ];
# This is the equivalent of running `brew install`
brews = [
"curl"
"openjdk"
];
# This is the equivalent of running `brew install --cask`
casks = [
"arc" # browser
"zed" # text editor
"raycast" # app launcher, and clipboard manager
"obsidian" # note taking
"inkscape" # vector graphics editor
];
};
};
}

12
darwin/system.nix Normal file
View file

@ -0,0 +1,12 @@
# This section apply settings to the system configuration only available on macOS
# see <https://daiderd.com/nix-darwin/manual/index.html#sec-options> for more options
{
system = {
# Add ability to used TouchID for sudo authentication
security.pam.enableSudoTouchIdAuth = true;
# Create /etc/zshrc that loads the nix-darwin environment.
# this is required if you want to use darwin's default shell - zsh
programs.zsh.enable = true;
};
}

9
darwin/users.nix Normal file
View file

@ -0,0 +1,9 @@
{ username, hostname, ... }:
{
# remember to set the hostname in the kernel command line
networking.hostName = hostname;
networking.computerName = hostname;
system.defaults.smb.NetBIOSName = hostname;
users.users."${username}".home = "/Users/${username}";
}

27
flake.lock Normal file
View file

@ -0,0 +1,27 @@
{
"nodes": {
"resevoir": {
"locked": {
"lastModified": 1714562304,
"narHash": "sha256-Mr3U37Rh6tH0FbaDFu0aZDwk9mPAe7ASaqDOGgLqqLU=",
"owner": "auxolotl",
"repo": "nixpkgs",
"rev": "bcd44e224fd68ce7d269b4f44d24c2220fd821e7",
"type": "github"
},
"original": {
"owner": "auxolotl",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"resevoir": "resevoir"
}
}
},
"root": "root",
"version": 7
}

36
flake.nix Normal file
View file

@ -0,0 +1,36 @@
{
description = "Templates for getting started with Aux";
inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable";
outputs =
{ self, nixpkgs }:
let
forAllSystems =
function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
] (system: function system);
in
{
templates = {
default = self.templates.direnv;
system = {
path = ./system;
description = "";
};
home-manager = {
path = ./home-manager;
description = "";
};
darwin = {
path = ./darwin;
description = "";
};
};
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
};
}

40
home-manager/flake.nix Normal file
View file

@ -0,0 +1,40 @@
{
description = "A simple home-manager flake using Aux";
inputs = {
nixpkgs.url = "github:auxolotl/nixkpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";
# The `follows` keyword in inputs is used for inheritance.
# we do this in order to prevent duplication of the nixpkgs input, and potential
# issues with diffrent versions of given packages.
# However, it should be noted that this can lead to having to rebuild packages from source.
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
username = builtins.abort "You need to fill in your username"; # Set this variable equal to your username
in
{
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [ ./home.nix ];
extraSpecialArgs = {
inherit username pkgs; # We inherit pkgs
};
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
};
};
}

81
home-manager/home.nix Normal file
View file

@ -0,0 +1,81 @@
{
config,
pkgs,
username,
...
}:
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home = {
inherit username;
homeDirectory = "/home/${username}";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
stateVersion = "23.11"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
packages = [
# # Adds the 'hello' command to your environment. It prints a friendly
# # "Hello, world!" when run.
# pkgs.hello
# # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
# # fonts?
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
file = {
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
# # symlink to the Nix store copy.
# ".screenrc".source = dotfiles/screenrc;
# # You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};
# Home Manager can also manage your environment variables through
# 'home.sessionVariables'. If you don't want to manage your shell through Home
# Manager then you have to manually source 'hm-session-vars.sh' located at
# either
#
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# /etc/profiles/per-user/abhiram/etc/profile.d/hm-session-vars.sh
#
sessionVariables = {
# EDITOR = "emacs";
};
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

138
system/configuration.nix Normal file
View file

@ -0,0 +1,138 @@
{
config,
lib,
pkgs,
username,
hostName,
...
}:
{
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = hostName; # Define your hostname.
# Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
# Set your time zone.
# time.timeZone = "Europe/Amsterdam";
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
# i18n.defaultLocale = "en_US.UTF-8";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# useXkbConfig = true; # use xkb.options in tty.
# };
# Enable the X11 windowing system.
# services.xserver.enable = true;
# Configure keymap in X11
# services.xserver.xkb.layout = "us";
# services.xserver.xkb.options = "eurosign:e,caps:escape";
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
# hardware.pulseaudio.enable = true;
# OR
# services.pipewire = {
# enable = true;
# pulse.enable = true;
# };
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users.${username} = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
packages = with pkgs; [ firefox ];
};
# List packages installed in system profile. To search, run:
# $ nix search wget
# environment.systemPackages = with pkgs; [
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
# wget
# ];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
# system.copySystemConfiguration = true;
# This option allows you to use some features (flakes and the new Nix CLI) which have not yet been stabilized.
# Although they aren't yet stabilized, many Nix users use them and simple workflows are unlikely to break
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
nix.registry.nixpkgs = {
from = {
id = "nixpkgs";
type = "indirect";
};
to = {
owner = "auxolotl";
repo = "nixpkgs";
type = "github";
};
};
nix.gc.automatic = true;
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
#
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
#
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
#
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
#
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "24.05"; # Did you read the comment?
}

23
system/flake.nix Normal file
View file

@ -0,0 +1,23 @@
{
description = "A simple system flake using some Aux defaults";
inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable";
outputs =
{ nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
hostName = builtins.abort "You need to fill in your hostName"; # Set this variable equal to your hostName
username = builtins.abort "You need to fill in your username"; # Set this variable equal to your username
in
{
nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem {
inherit system;
modules = [ ./configuration.nix ];
specialArgs = {
inherit inputs;
};
};
};
}

View file

@ -0,0 +1 @@
builtins.abort "Please run 'nixos-generate-config --show-hardware-config' and copy the output into hardware-configuration.nix"