From b4116247ca2eec16b4048a5222fcd7c73c89f5fd Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Fri, 28 Jul 2023 17:15:33 -0500 Subject: [PATCH] more packages, more modular --- flake.lock | 16 ++++ flake.nix | 85 ++++++------------- nix/home/features/cli/default.nix | 25 ++++++ nix/{lib => home/features/cli}/tmux.nix | 0 nix/{lib => home/features/cli}/vim.nix | 0 nix/home/features/desktop/default.nix | 12 +++ nix/{lib => home/features/desktop}/vscode.nix | 7 -- nix/home/{common.nix => global/default.nix} | 40 ++++----- nix/home/lib/chromeos.nix | 15 ++++ nix/home/penguin-duet.nix | 12 +-- nix/home/penguin-fw.nix | 19 +---- nix/modules/home-manager/default.nix | 2 +- nix/pkgs/default.nix | 1 + nix/pkgs/trekscii/default.nix | 23 +++++ nix/shell.nix => shell.nix | 0 15 files changed, 144 insertions(+), 113 deletions(-) create mode 100644 nix/home/features/cli/default.nix rename nix/{lib => home/features/cli}/tmux.nix (100%) rename nix/{lib => home/features/cli}/vim.nix (100%) create mode 100644 nix/home/features/desktop/default.nix rename nix/{lib => home/features/desktop}/vscode.nix (98%) rename nix/home/{common.nix => global/default.nix} (69%) create mode 100644 nix/home/lib/chromeos.nix create mode 100644 nix/pkgs/trekscii/default.nix rename nix/shell.nix => shell.nix (100%) diff --git a/flake.lock b/flake.lock index 8f7795d..e1a6472 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "hardware": { + "locked": { + "lastModified": 1690200740, + "narHash": "sha256-aRkEXGmCbAGcvDcdh/HB3YN+EvoPoxmJMOaqRZmf6vM=", + "owner": "nixos", + "repo": "nixos-hardware", + "rev": "ba9650b14e83b365fb9e731f7d7c803f22d2aecf", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixos-hardware", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -55,6 +70,7 @@ }, "root": { "inputs": { + "hardware": "hardware", "home-manager": "home-manager", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable" diff --git a/flake.nix b/flake.nix index d59ef8d..7e764b1 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,11 @@ { description = "A Very Flakey Home Manager"; + # Initial layout shamelessly stolen from: + # - https://github.com/Misterio77/nix-starter-configs/ + # - https://github.com/Misterio77/nix-config/ + inputs = { - # Nixpkgs nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; # You can access packages and modules from different nixpkgs revs # at the same time. Here's a working example: @@ -15,81 +18,49 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - # TODO: Add any other flake you might need - # hardware.url = "github.com/nixos/nixos-hardware"; + # Hardware + hardware.url = "github:nixos/nixos-hardware"; }; - outputs = { self, nixpkgs, home-manager, ... }@inputs: + outputs = { self, nixpkgs, home-manager, ... } @ inputs: let inherit (self) outputs; - forAllSystems = nixpkgs.lib.genAttrs [ - "aarch64-linux" - "x86_64-linux" - ]; + lib = nixpkgs.lib // home-manager.lib; + systems = [ "x86_64-linux" "aarch64-linux" ]; + forEachSystem = f: lib.genAttrs systems (sys: f pkgsFor.${sys}); + pkgsFor = nixpkgs.legacyPackages; in - rec { - # Your custom packages - # Accessible through 'nix build', 'nix shell', etc - packages = forAllSystems (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in import ./nix/pkgs { inherit pkgs; } - ); - # Devshell for bootstrapping - # Accessible through 'nix develop' or 'nix-shell' (legacy) - devShells = forAllSystems (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in import ./nix/shell.nix { inherit pkgs; } - ); - - # Your custom packages and modifications, exported as overlays - overlays = import ./nix/overlays { inherit inputs; }; - # Reusable nixos modules you might want to export - # These are usually stuff you would upstream into nixpkgs + { + inherit lib; nixosModules = import ./nix/modules/nixos; - # Reusable home-manager modules you might want to export - # These are usually stuff you would upstream into home-manager homeManagerModules = import ./nix/modules/home-manager; - # NixOS configuration entrypoint - # Available through 'nixos-rebuild --flake .#your-hostname' + overlays = import ./nix/overlays { inherit inputs outputs; }; + + packages = forEachSystem (pkgs: import ./nix/pkgs { inherit pkgs; }); + devShells = forEachSystem (pkgs: import ./shell.nix { inherit pkgs; }); + formatter = forEachSystem (pkgs: pkgs.nixpkgs-fmt); + nixosConfigurations = { - pixnix = nixpkgs.lib.nixosSystem { + # Pixelbook converted to NixOS + pixnix = lib.nixosSystem { + modules = [ ./nix/hosts/pixnix ]; specialArgs = { inherit inputs outputs; }; - modules = [ - # > Our main nixos configuration file < - ./nix/nixos/configuration.nix - ]; }; }; # Standalone home-manager configuration entrypoint # Available through 'home-manager --flake .#your-username@your-hostname' homeConfigurations = { - "john@penguin-fw" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; + "john@penguin-fw" = lib.homeManagerConfiguration { + modules = [ ./nix/home/penguin-fw.nix ]; + pkgs = pkgsFor.x86_64-linux; extraSpecialArgs = { inherit inputs outputs; }; - modules = [ - ./nix/home/penguin-fw.nix - { - home = { - username = "john"; - homeDirectory = "/home/john"; - }; - } - ]; }; - "john@penguin-duet" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.aarch64-linux; + "john@penguin-duet" = lib.homeManagerConfiguration { + modules = [ ./nix/home/penguin-duet.nix ]; + pkgs = pkgsFor.aarch64-linux; extraSpecialArgs = { inherit inputs outputs; }; - modules = [ - ./nix/home/penguin-duet.nix - { - home = { - username = "john"; - homeDirectory = "/home/john"; - }; - } - ]; }; }; }; diff --git a/nix/home/features/cli/default.nix b/nix/home/features/cli/default.nix new file mode 100644 index 0000000..50f009a --- /dev/null +++ b/nix/home/features/cli/default.nix @@ -0,0 +1,25 @@ +{ pkgs, ... }: { + # Common CLI apps + + imports = [ + ./tmux.nix + ./vim.nix + ]; + + home.packages = with pkgs; [ + babelfish # Lets fish speak bash + bottom # Better top + httpie # Better curl + hugo # Static site generator + jq # JSON pretty printer and manipulator + nil # Nix LSP + # nix-inspect # See which pkgs are in your Path + nixfmt # Nix formatter + packer # Hashicorp packer + powershell # Powershell + terraform # Hashicorp terraform + tldr # TLDR pages + trekscii # Cute startrek cli printer + vault # Hashicorp vault + ]; +} \ No newline at end of file diff --git a/nix/lib/tmux.nix b/nix/home/features/cli/tmux.nix similarity index 100% rename from nix/lib/tmux.nix rename to nix/home/features/cli/tmux.nix diff --git a/nix/lib/vim.nix b/nix/home/features/cli/vim.nix similarity index 100% rename from nix/lib/vim.nix rename to nix/home/features/cli/vim.nix diff --git a/nix/home/features/desktop/default.nix b/nix/home/features/desktop/default.nix new file mode 100644 index 0000000..3d23334 --- /dev/null +++ b/nix/home/features/desktop/default.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: { + # Common GUI apps + imports = [ + ./vscode.nix + ]; + + home.packages = with pkgs; [ + firefox-esr + obsidian + qFlipper + ]; +} \ No newline at end of file diff --git a/nix/lib/vscode.nix b/nix/home/features/desktop/vscode.nix similarity index 98% rename from nix/lib/vscode.nix rename to nix/home/features/desktop/vscode.nix index a1decc9..d5736b2 100644 --- a/nix/lib/vscode.nix +++ b/nix/home/features/desktop/vscode.nix @@ -1,12 +1,5 @@ { outputs, pkgs, lib, ... }: { - nixpkgs = { - config = { - allowUnfree = true; - allowUnfreePredicate = (_: true); - }; - }; - programs.vscode = { enable = true; enableExtensionUpdateCheck = false; diff --git a/nix/home/common.nix b/nix/home/global/default.nix similarity index 69% rename from nix/home/common.nix rename to nix/home/global/default.nix index 12d32b1..60c0787 100644 --- a/nix/home/common.nix +++ b/nix/home/global/default.nix @@ -1,32 +1,29 @@ { inputs, outputs, lib, config, pkgs, ... }: { imports = [ - ../lib/tmux.nix - ../lib/vim.nix - ]; + ../features/cli + ] ++ (builtins.attrValues outputs.homeManagerModules); - nixpkgs.config = { - allowUnfree = true; - allowUnfreePredicate = (_: true); + nixpkgs = { + overlays = builtins.attrValues outputs.overlays; + config = { + allowUnfree = true; + allowUnfreePredicate = (_: true); + }; + }; + + nix = { + package = lib.mkDefault pkgs.nix; + settings = { + experimental-features = ["nix-command" "flakes" "repl-flake" ]; + warn-dirty = false; + }; }; home = { + username = lib.mkDefault "john"; homeDirectory = lib.mkDefault "/home/${config.home.username}"; stateVersion = lib.mkDefault "23.05"; - file = { - - }; - - packages = with pkgs; [ - babelfish - hugo - packer - powershell - terraform - tldr - vault - ]; - sessionVariables = { EDITOR = "vim"; }; @@ -59,9 +56,6 @@ }; }; - htop.enable = lib.mkDefault true; - - jq.enable = lib.mkDefault true; }; diff --git a/nix/home/lib/chromeos.nix b/nix/home/lib/chromeos.nix new file mode 100644 index 0000000..dc4c678 --- /dev/null +++ b/nix/home/lib/chromeos.nix @@ -0,0 +1,15 @@ +{ pkgs, lib, ... }: { + # ChromeOS integration + + home.file.".config/systemd/user/cros-garcon.service.d/override.conf" = { + text = '' + [Service] + Environment="PATH=%h/.nix-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/local/games:/usr/sbin:/usr/bin:/usr/games:/sbin:/bin" + Environment="XDG_DATA_DIRS=/nix/var/nix/profiles/default/share:%h/.nix-profile/share:%h/.local/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop:%h/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share" + ''; + }; + + # XDG settings + xdg.enable = true; + xdg.mime.enable = true; +} \ No newline at end of file diff --git a/nix/home/penguin-duet.nix b/nix/home/penguin-duet.nix index 122cb32..07f86be 100644 --- a/nix/home/penguin-duet.nix +++ b/nix/home/penguin-duet.nix @@ -1,19 +1,11 @@ { pkgs, lib, config, ... }: { imports = [ - ./home/common.nix + ./global + ./lib/chromeos.nix ]; - nixpkgs.config = { - allowUnfree = true; - allowUnfreePredicate = (_: true); - }; - # packages home.packages = with pkgs; [ obsidian ]; - - # XDG settings - xdg.enable = true; - xdg.mime.enable = true; } diff --git a/nix/home/penguin-fw.nix b/nix/home/penguin-fw.nix index f119e1b..c1458d2 100644 --- a/nix/home/penguin-fw.nix +++ b/nix/home/penguin-fw.nix @@ -1,24 +1,13 @@ -{ pkgs, lib, config, ... }: { +{ inputs, outputs, lib, config, pkgs, ... }: { imports = [ - ./common.nix - ../lib/vscode.nix + ./global + ./features/desktop + ./lib/chromeos.nix ]; - nixpkgs.config = { - allowUnfree = true; - allowUnfreePredicate = (_: true); - }; - # packages home.packages = with pkgs; [ - firefox-esr libvirt - obsidian - qFlipper vagrant ]; - - # XDG settings - xdg.enable = true; - xdg.mime.enable = true; } diff --git a/nix/modules/home-manager/default.nix b/nix/modules/home-manager/default.nix index b6d8e49..e41f7d9 100644 --- a/nix/modules/home-manager/default.nix +++ b/nix/modules/home-manager/default.nix @@ -4,4 +4,4 @@ { # List your module files here # my-module = import ./my-module.nix; -} \ No newline at end of file +} diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix index d0f8674..2c27402 100644 --- a/nix/pkgs/default.nix +++ b/nix/pkgs/default.nix @@ -3,4 +3,5 @@ { pkgs ? (import ../nixpkgs.nix) { } }: { # example = pkgs.callPackage ./example { }; + trekscii = pkgs.callPackage ./trekscii { }; } \ No newline at end of file diff --git a/nix/pkgs/trekscii/default.nix b/nix/pkgs/trekscii/default.nix new file mode 100644 index 0000000..e8c2a88 --- /dev/null +++ b/nix/pkgs/trekscii/default.nix @@ -0,0 +1,23 @@ +{ lib, stdenv, fetchFromGitHub }: +let + pname = "trekscii"; +in +stdenv.mkDerivation { + inherit pname; + version = "unstable-2022-06-27"; + + src = fetchFromGitHub { + owner = "k-vernooy"; + repo = pname; + rev = "8b51971c4c62f49f886d59f2c8445ce8734b00e8"; + hash = "sha256-Mn3wasplwXsDCBEpHLqdh0G+SqYIirj7lKvM3VehPH0="; + }; + + installPhase = '' + install -Dm 0755 bin/trekscii $out/bin/trekscii + ''; + + meta = with lib; { + platforms = platforms.all; + }; +} \ No newline at end of file diff --git a/nix/shell.nix b/shell.nix similarity index 100% rename from nix/shell.nix rename to shell.nix