Skip to content

Commit

Permalink
feat: system packages and suites
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehamilton committed Dec 29, 2021
1 parent 45f03d7 commit 4a025a0
Show file tree
Hide file tree
Showing 46 changed files with 453 additions and 130 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# macOS adds a file when opening a directory with Finder.
.DS_Store

# Running `nixos-rebuild build` or `nix build` generates a result directory.
result
.DS_Store

# Running `nixos-rebuild build-vm` and starting the VM adds a file for
# the virtual storage drive.
*.qcow2
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@
outputs = inputs@{ self, nixpkgs, nixpkgs-unstable, home-manager, utils
, nixos-hardware, darwin, ... }:
let lib = import ./lib inputs;
pkgs = import nixpkgs {
system = "x86_64-linux";
allowUnfree = true;
};
in utils.lib.mkFlake {
inherit self inputs lib;

channelsConfig = { allowUnfree = true; };

channels.nixpkgs.overlaysBuilder = lib.mkOverlays [
"steam"
];

hosts = lib.mkHosts { src = ./machines; };
# hosts.jasper.modules = builtins.trace (lib.getFiles ./machines)
# (lib.getFiles ./machines);
};
}
7 changes: 7 additions & 0 deletions lib/fp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@ rec {
# The inverse of `call`. Given an argument, call the next
# function provided with it.
apply = flip2 call;

# Map from builtins provided for ease of use with map'.
map = builtins.map;

# The inverse of `map`. Given a list, map it with the next
# function provided.
map' = flip2 map;
}
13 changes: 13 additions & 0 deletions lib/fs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,17 @@ in rec {
getModuleFilesWithoutDefault = path:
builtins.filter (file: lib.not "default.nix" (builtins.baseNameOf file))
(getModuleFiles path);

getPathFromRoot = path:
../. + (if lib.hasPrefix "/" path then path else "/${path}");

getSuitePath = name: getPathFromRoot "/suites/${name}.nix";

getPresetPath = name: getPathFromRoot "/presets/${name}.nix";

getModulePath = name: getPathFromRoot "/modules/${name}.nix";

getUserPath = name: getPathFromRoot "/users/${name}";

getOverlayPath = name: getPathFromRoot "/overlays/${name}.nix";
}
4 changes: 2 additions & 2 deletions lib/machine.nix → lib/host.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ rec {
};

mkHost = { system, path, name ? lib.getFileName (builtins.baseNameOf path)
, modules ? [ ], specialArgs ? { } }: {
, modules ? [ ], specialArgs ? { }, channelName ? "nixpkgs" }: {
"${name}" = withDynamicConfig system {
inherit system;
inherit system channelName;
modules = [ path ] ++ modules;
specialArgs = mkSpecialArgs specialArgs;
};
Expand Down
8 changes: 8 additions & 0 deletions lib/overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
inputs@{ lib, ... }:

rec {
mkOverlays = names: channels:
lib.map
(name: import (lib.getOverlayPath name) (inputs // { inherit channels; }))
names;
}
15 changes: 15 additions & 0 deletions lib/system.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
inputs@{ lib, ... }:

rec {
mkSystem = { hardware ? null, suites ? [ ], presets ? [ ], modules ? [ ]
, users ? [ ], config ? { }, }:
let
suitePaths = lib.map lib.getSuitePath suites;
presetPaths = lib.map lib.getPresetPath presets;
modulePaths = lib.map lib.getModulePath modules;
userPaths = lib.map lib.getUserPath users;
imports = (lib.optional (lib.not null hardware) hardware)
++ (lib.optional (builtins.hasAttr "imports" config) config.imports)
++ suitePaths ++ presetPaths ++ modulePaths ++ userPaths;
in config // { inherit imports; };
}
54 changes: 30 additions & 24 deletions machines/x86_64-linux/jasper/default.nix
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
inputs@{ pkgs, lib, ... }:

{
imports = [
# Hardware configuration for the system.
./hardware.nix
lib.mkSystem {
# Hardware configuration for the system.
hardware = ./hardware.nix;

# Presets
../../../presets/nix.nix
../../../presets/boot.nix
../../../presets/locale.nix
../../../presets/gnome.nix
../../../presets/networking.nix
../../../presets/audio.nix
../../../presets/fonts.nix
../../../presets/dev.nix
suites = [
"nixos"
"desktop"
"apps"
"games"
"dev"
];

presets = [
];

modules = [
"fprintd"
];

# Users
../../../users/short
users = [
"short"
];

# Enable DHCP on the wireless link
networking.interfaces.wlp0s20f3.useDHCP = true;
config = {
# Enable DHCP on the wireless link
networking.interfaces.wlp0s20f3.useDHCP = true;

# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.11"; # Did you read the comment?
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.11"; # Did you read the comment?
};
}
13 changes: 12 additions & 1 deletion machines/x86_64-linux/jasper/hardware.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,16 @@
lib.mkDefault config.hardware.enableRedistributableFirmware;

# high-resolution display
hardware.video.hidpi.enable = lib.mkDefault true;
hardware.video.hidpi.enable = true;

hardware.opengl = {
enable = true;

extraPackages = with pkgs; [
intel-media-driver # LIBVA_DRIVER_NAME=iHD
vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
vaapiVdpau
libvdpau-va-gl
];
};
}
8 changes: 8 additions & 0 deletions modules/1password.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
inputs@{pkgs, ... }:

{
environment.systemPackages = with pkgs; [
_1password
_1password-gui
];
}
5 changes: 5 additions & 0 deletions modules/discord.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ pkgs, ... }:

{
environment.systemPackages = with pkgs; [ discord ];
}
6 changes: 2 additions & 4 deletions modules/firefox.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{ pkgs, ... }:

{
environment.systemPackages = with pkgs; [
firefox
];
}
environment.systemPackages = with pkgs; [ firefox ];
}
14 changes: 6 additions & 8 deletions modules/fonts.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{ pkgs, ... }:

{
fonts.fonts = with pkgs; [
noto-fonts
noto-fonts-emoji
(nerdfonts.override {
fonts = [ "Hack" "DroidSansMono" ];
})
];
}
fonts.fonts = with pkgs; [
noto-fonts
noto-fonts-emoji
(nerdfonts.override { fonts = [ "Hack" "DroidSansMono" ]; })
];
}
4 changes: 2 additions & 2 deletions modules/fprintd.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ ... }:

{
services.fprintd.enable = true;
}
services.fprintd.enable = true;
}
6 changes: 2 additions & 4 deletions modules/git.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{ pkgs, ... }:

{
environment.systemPackages = with pkgs; [
git
];
}
environment.systemPackages = with pkgs; [ git ];
}
18 changes: 10 additions & 8 deletions modules/gnome.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{ ... }:

{
services.xserver = {
enable = true;
services.xserver = {
enable = true;

displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
layout = "us";
xkbOptions = "caps:escape";
};
libinput.enable = true;
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
layout = "us";
xkbOptions = "caps:swapescape";

}
};

}
10 changes: 10 additions & 0 deletions modules/home-manager.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
inputs@{ lib, home-manager, ... }:

{
imports = [
home-manager.nixosModules.home-manager
];

home-manager.useGlobalPkgs = true;
home-manager.useUserPkgs = true;
}
8 changes: 3 additions & 5 deletions modules/locale.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{ lib, ... }:

{
i18n.defaultLocale = "en_US.UTF-8";
i18n.defaultLocale = "en_US.UTF-8";

console = {
keyMap = lib.mkDefault "us";
};
}
console = { keyMap = lib.mkDefault "us"; };
}
6 changes: 2 additions & 4 deletions modules/neovim.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{ pkgs, ... }:

{
environment.systemPackages = with pkgs; [
neovim
];
}
environment.systemPackages = with pkgs; [ neovim ];
}
4 changes: 2 additions & 2 deletions modules/printing.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ ... }:

{
services.printing.enable = true;
}
services.printing.enable = true;
}
6 changes: 3 additions & 3 deletions modules/pulseaudio.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ ... }:

{
sound.enable = true;
hardware.pulseaudio.enable = true;
}
sound.enable = true;
hardware.pulseaudio.enable = true;
}
Loading

0 comments on commit 4a025a0

Please sign in to comment.