From 78b67b490d763c7d54556215ab57bafa5793b3cc Mon Sep 17 00:00:00 2001 From: Sam Nystrom Date: Mon, 27 Mar 2023 18:49:50 -0400 Subject: [PATCH] feat!: switch to NixOS/HM modules --- .github/dependabot.yml | 6 ---- .github/workflows/build.yml | 52 ------------------------------- ci.nix | 53 -------------------------------- default.nix | 20 ------------ flake.lock | 27 ---------------- flake.nix | 25 ++++----------- home-manager/bat.nix | 31 +++++++++++++++++++ home-manager/default.nix | 9 ++++++ lib/default.nix | 7 ----- modules/default.nix | 5 --- nixos/default.nix | 1 + overlay.nix | 15 --------- overlays/default.nix | 5 --- pkgs/example-package/default.nix | 9 ------ 14 files changed, 47 insertions(+), 218 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/build.yml delete mode 100644 ci.nix delete mode 100644 default.nix delete mode 100644 flake.lock create mode 100644 home-manager/bat.nix create mode 100644 home-manager/default.nix delete mode 100644 lib/default.nix delete mode 100644 modules/default.nix create mode 100644 nixos/default.nix delete mode 100644 overlay.nix delete mode 100644 overlays/default.nix delete mode 100644 pkgs/example-package/default.nix diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index ca79ca5..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: weekly diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 6b814d5..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: "Build and populate cache" -on: - pull_request: - push: - branches: - - main - schedule: - - cron: '12 9 * * *' - -jobs: - tests: - strategy: - matrix: - nurRepo: - - https://gitub.com/catppuccin/nix - cachixName: - - # TODO - nixPath: - - nixpkgs=channel:nixos-unstable - - nixpkgs=channel:nixpkgs-unstable - - nixpkgs=channel:nixos-22.11 - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Install nix - uses: cachix/install-nix-action@v20 - with: - nix_path: "${{ matrix.nixPath }}" - extra_nix_config: | - experimental-features = nix-command flakes - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - name: Show nixpkgs version - run: nix-instantiate --eval -E '(import {}).lib.version' - # - name: Setup cachix - # uses: cachix/cachix-action@v12 - # with: - # name: ${{ matrix.cachixName }} - # authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: Check evaluation - run: | - nix-env -f . -qa \* --meta --xml \ - --allowed-uris https://static.rust-lang.org \ - --option restrict-eval true \ - --option allow-import-from-derivation true \ - --drv-path --show-trace \ - -I nixpkgs=$(nix-instantiate --find-file nixpkgs) \ - -I $PWD - - name: Build nix packages - run: nix shell -f '' nix-build-uncached -c nix-build-uncached ci.nix -A cacheOutputs - # - name: Trigger NUR update - # run: curl -XPOST "https://nur-update.nix-community.org/update?repo=${{ matrix.nurRepo }}" diff --git a/ci.nix b/ci.nix deleted file mode 100644 index 22b1352..0000000 --- a/ci.nix +++ /dev/null @@ -1,53 +0,0 @@ -# This file provides all the buildable and cacheable packages and -# package outputs in your package set. These are what gets built by CI, -# so if you correctly mark packages as -# -# - broken (using `meta.broken`), -# - unfree (using `meta.license.free`), and -# - locally built (using `preferLocalBuild`) -# -# then your CI will be able to build and cache only those packages for -# which this is possible. - -{ pkgs ? import { } }: - -with builtins; -let - isReserved = n: n == "lib" || n == "overlays" || n == "modules"; - isDerivation = p: isAttrs p && p ? type && p.type == "derivation"; - isBuildable = p: !(p.meta.broken or false) && p.meta.license.free or true; - isCacheable = p: !(p.preferLocalBuild or false); - shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false; - - nameValuePair = n: v: { name = n; value = v; }; - - concatMap = builtins.concatMap or (f: xs: concatLists (map f xs)); - - flattenPkgs = s: - let - f = p: - if shouldRecurseForDerivations p then flattenPkgs p - else if isDerivation p then [ p ] - else [ ]; - in - concatMap f (attrValues s); - - outputsOf = p: map (o: p.${o}) p.outputs; - - nurAttrs = import ./default.nix { inherit pkgs; }; - - nurPkgs = - flattenPkgs - (listToAttrs - (map (n: nameValuePair n nurAttrs.${n}) - (filter (n: !isReserved n) - (attrNames nurAttrs)))); - -in -rec { - buildPkgs = filter isBuildable nurPkgs; - cachePkgs = filter isCacheable buildPkgs; - - buildOutputs = concatMap outputsOf buildPkgs; - cacheOutputs = concatMap outputsOf cachePkgs; -} diff --git a/default.nix b/default.nix deleted file mode 100644 index d6497c9..0000000 --- a/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -# This file describes your repository contents. -# It should return a set of nix derivations -# and optionally the special attributes `lib`, `modules` and `overlays`. -# It should NOT import . Instead, you should take pkgs as an argument. -# Having pkgs default to is fine though, and it lets you use short -# commands such as: -# nix-build -A mypackage - -{ pkgs ? import { } }: - -{ - # The `lib`, `modules`, and `overlay` names are special - lib = import ./lib { inherit pkgs; }; # functions - modules = import ./modules; # NixOS modules - overlays = import ./overlays; # nixpkgs overlays - - example-package = pkgs.callPackage ./pkgs/example-package { }; - # some-qt5-package = pkgs.libsForQt5.callPackage ./pkgs/some-qt5-package { }; - # ... -} diff --git a/flake.lock b/flake.lock deleted file mode 100644 index a804412..0000000 --- a/flake.lock +++ /dev/null @@ -1,27 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1624561540, - "narHash": "sha256-izJ2PYZMGMsSkg+e7c9A1x3t/yOLT+qzUM6WQsc2tqo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "c6a049a3d32293b24c0f894a840872cf67fd7c11", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix index 4c84ed7..8d54441 100644 --- a/flake.nix +++ b/flake.nix @@ -1,21 +1,8 @@ { - description = "My personal NUR repository"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - outputs = { self, nixpkgs }: - let - systems = [ - "x86_64-linux" - "i686-linux" - "x86_64-darwin" - "aarch64-linux" - "armv6l-linux" - "armv7l-linux" - ]; - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); - in - { - packages = forAllSystems (system: import ./default.nix { - pkgs = import nixpkgs { inherit system; }; - }); - }; + description = "Soothing pastel theme for Nix"; + inputs = {}; + outputs = { self }: { + nixosModules.default = import ./nixos; + homeManagerModules.default = import ./home-manager; + }; } diff --git a/home-manager/bat.nix b/home-manager/bat.nix new file mode 100644 index 0000000..d967386 --- /dev/null +++ b/home-manager/bat.nix @@ -0,0 +1,31 @@ +{ config, pkgs, lib, ... }: { + options.programs.bat.catppuccin = { + enable = lib.mkEnableOption "Catppuccin"; + flavour = lib.mkOption { + type = lib.types.enum [ "latte" "frappe" "macchiato" "mocha" ]; + default = config.catppuccin.flavour; + description = "Catppuccin flavour for bat"; + }; + }; + + config = let + cfg = config.programs.bat.catppuccin; + in + { + home.activation = { + batCache = "${pkgs.bat}/bin/bat cache --build"; + }; + + programs.bat = lib.mkIf cfg.enable { + enable = true; + config.theme = "Catppuccin-${cfg.flavour}"; + themes."Catppuccin-${cfg.flavour}" = builtins.readFile (pkgs.fetchFromGitHub + { + owner = "catppuccin"; + repo = "bat"; + rev = "ba4d16880d63e656acced2b7d4e034e4a93f74b1"; + sha256 = "sha256-6WVKQErGdaqb++oaXnY3i6/GuH2FhTgK0v4TN4Y0Wbw="; + } + /Catppuccin-${cfg.flavour}.tmTheme); + }; + }; +} diff --git a/home-manager/default.nix b/home-manager/default.nix new file mode 100644 index 0000000..86f0f04 --- /dev/null +++ b/home-manager/default.nix @@ -0,0 +1,9 @@ +{ config, pkgs, lib, ... }: { + options.catppuccin = { + flavour = lib.mkOption { + type = lib.types.enum [ "latte" "frappe" "macchiato" "mocha" ]; + default = "latte"; + description = "Global Catppuccin flavour"; + }; + }; +} diff --git a/lib/default.nix b/lib/default.nix deleted file mode 100644 index a7fab1d..0000000 --- a/lib/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs }: - -with pkgs.lib; { - # Add your library functions here - # - # hexint = x: hexvals.${toLower x}; -} diff --git a/modules/default.nix b/modules/default.nix deleted file mode 100644 index ff6c7c0..0000000 --- a/modules/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - # Add your NixOS modules here - # - # my-module = ./my-module; -} diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 0000000..908fef4 --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1 @@ +{ pkgs, lib, ... }: {} diff --git a/overlay.nix b/overlay.nix deleted file mode 100644 index bff7396..0000000 --- a/overlay.nix +++ /dev/null @@ -1,15 +0,0 @@ -# You can use this file as a nixpkgs overlay. This is useful in the -# case where you don't want to add the whole NUR namespace to your -# configuration. - -self: super: -let - isReserved = n: n == "lib" || n == "overlays" || n == "modules"; - nameValuePair = n: v: { name = n; value = v; }; - nurAttrs = import ./default.nix { pkgs = super; }; - -in -builtins.listToAttrs - (map (n: nameValuePair n nurAttrs.${n}) - (builtins.filter (n: !isReserved n) - (builtins.attrNames nurAttrs))) diff --git a/overlays/default.nix b/overlays/default.nix deleted file mode 100644 index 0c2d870..0000000 --- a/overlays/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - # Add your overlays here - # - # my-overlay = import ./my-overlay; -} diff --git a/pkgs/example-package/default.nix b/pkgs/example-package/default.nix deleted file mode 100644 index 41e22df..0000000 --- a/pkgs/example-package/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ stdenv }: - -stdenv.mkDerivation rec { - name = "example-package-${version}"; - version = "1.0"; - src = ./.; - buildPhase = "echo echo Hello World > example"; - installPhase = "install -Dm755 example $out"; -}