aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml8
-rw-r--r--LICENSE1
-rw-r--r--README.md34
-rw-r--r--ci.nix46
-rw-r--r--default.nix12
-rw-r--r--flake.lock29
-rw-r--r--flake.nix39
-rw-r--r--lib/default.nix3
-rw-r--r--overlay.nix14
-rw-r--r--pkgs/git-helpers/default.nix24
-rw-r--r--pkgs/hgrep/default.nix56
-rw-r--r--pkgs/reparojson/default.nix25
-rw-r--r--pkgs/term-banner/default.nix25
-rw-r--r--pkgs/term-clock/default.nix38
-rw-r--r--treefmt.nix5
15 files changed, 286 insertions, 73 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d598d63..144bf60 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -6,10 +6,10 @@ on:
- main
- master
schedule:
- # rebuild everyday at 2:51
+ # rebuild everyday at 5:55
# TIP: Choose a random time here so not all repositories are build at once:
# https://www.random.org/clock-times/?num=1&earliest=01%3A00&latest=08%3A00&interval=5&format=html&rnd=new
- - cron: '51 2 * * *'
+ - cron: '55 5 * * *'
workflow_dispatch:
jobs:
tests:
@@ -36,8 +36,8 @@ jobs:
- <YOUR_CACHIX_NAME>
nixPath:
- nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixpkgs-unstable.tar.gz
- - nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-unstable.tar.gz
- - nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-24.05.tar.gz
+ # - nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-unstable.tar.gz
+ # - nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-24.05.tar.gz
runs-on: ubuntu-latest
steps:
- name: Checkout repository
diff --git a/LICENSE b/LICENSE
index 212cbf2..aae7063 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,7 @@
MIT License
Copyright (c) 2018 Francesco Gazzetta
+Copyright (c) 2025 nsfisis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 077cfbc..4182a7f 100644
--- a/README.md
+++ b/README.md
@@ -1,37 +1,5 @@
-# nur-packages-template
-
-**A template for [NUR](https://github.com/nix-community/NUR) repositories**
-
-## Setup
-
-1. Click on [Use this template](https://github.com/nix-community/nur-packages-template/generate) to start a repo based on this template. (Do _not_ fork it.)
-2. Add your packages to the [pkgs](./pkgs) directory and to
- [default.nix](./default.nix)
- * Remember to mark the broken packages as `broken = true;` in the `meta`
- attribute, or travis (and consequently caching) will fail!
- * Library functions, modules and overlays go in the respective directories
-3. Choose your CI: Depending on your preference you can use github actions (recommended) or [Travis ci](https://travis-ci.com).
- - Github actions: Change your NUR repo name and optionally add a cachix name in [.github/workflows/build.yml](./.github/workflows/build.yml) and change the cron timer
- to a random value as described in the file
- - Travis ci: Change your NUR repo name and optionally your cachix repo name in
- [.travis.yml](./.travis.yml). Than enable travis in your repo. You can add a cron job in the repository settings on travis to keep your cachix cache fresh
-5. Change your travis and cachix names on the README template section and delete
- the rest
-6. [Add yourself to NUR](https://github.com/nix-community/NUR#how-to-add-your-own-repository)
-
-## README template
-
# nur-packages
**My personal [NUR](https://github.com/nix-community/NUR) repository**
-<!-- Remove this if you don't use github actions -->
-![Build and populate cache](https://github.com/<YOUR-GITHUB-USER>/nur-packages/workflows/Build%20and%20populate%20cache/badge.svg)
-
-<!--
-Uncomment this if you use travis:
-
-[![Build Status](https://travis-ci.com/<YOUR_TRAVIS_USERNAME>/nur-packages.svg?branch=master)](https://travis-ci.com/<YOUR_TRAVIS_USERNAME>/nur-packages)
--->
-[![Cachix Cache](https://img.shields.io/badge/cachix-<YOUR_CACHIX_CACHE_NAME>-blue.svg)](https://<YOUR_CACHIX_CACHE_NAME>.cachix.org)
-
+![Build and populate cache](https://github.com/nsfisis/nur-packages/workflows/Build%20and%20populate%20cache/badge.svg)
diff --git a/ci.nix b/ci.nix
index f84dd96..4fa1017 100644
--- a/ci.nix
+++ b/ci.nix
@@ -9,29 +9,42 @@
# then your CI will be able to build and cache only those packages for
# which this is possible.
-{ pkgs ? import <nixpkgs> { } }:
+{
+ pkgs ? import <nixpkgs> { },
+}:
with builtins;
let
isReserved = n: n == "lib" || n == "overlays" || n == "modules";
isDerivation = p: isAttrs p && p ? type && p.type == "derivation";
- isBuildable = p: let
- licenseFromMeta = p.meta.license or [];
- licenseList = if builtins.isList licenseFromMeta then licenseFromMeta else [licenseFromMeta];
- in !(p.meta.broken or false) && builtins.all (license: license.free or true) licenseList;
+ isBuildable =
+ p:
+ let
+ licenseFromMeta = p.meta.license or [ ];
+ licenseList = if builtins.isList licenseFromMeta then licenseFromMeta else [ licenseFromMeta ];
+ in
+ !(p.meta.broken or false) && builtins.all (license: license.free or true) licenseList;
isCacheable = p: !(p.preferLocalBuild or false);
shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false;
- nameValuePair = n: v: { name = n; value = v; };
+ nameValuePair = n: v: {
+ name = n;
+ value = v;
+ };
concatMap = builtins.concatMap or (f: xs: concatLists (map f xs));
- flattenPkgs = s:
+ flattenPkgs =
+ s:
let
- f = p:
- if shouldRecurseForDerivations p then flattenPkgs p
- else if isDerivation p then [ p ]
- else [ ];
+ f =
+ p:
+ if shouldRecurseForDerivations p then
+ flattenPkgs p
+ else if isDerivation p then
+ [ p ]
+ else
+ [ ];
in
concatMap f (attrValues s);
@@ -39,12 +52,11 @@ let
nurAttrs = import ./default.nix { inherit pkgs; };
- nurPkgs =
- flattenPkgs
- (listToAttrs
- (map (n: nameValuePair n nurAttrs.${n})
- (filter (n: !isReserved n)
- (attrNames nurAttrs))));
+ nurPkgs = flattenPkgs (
+ listToAttrs (
+ map (n: nameValuePair n nurAttrs.${n}) (filter (n: !isReserved n) (attrNames nurAttrs))
+ )
+ );
in
rec {
diff --git a/default.nix b/default.nix
index 3846c24..5a3ea2e 100644
--- a/default.nix
+++ b/default.nix
@@ -6,7 +6,9 @@
# commands such as:
# nix-build -A mypackage
-{ pkgs ? import <nixpkgs> { } }:
+{
+ pkgs ? import <nixpkgs> { },
+}:
{
# The `lib`, `modules`, and `overlays` names are special
@@ -15,6 +17,10 @@
overlays = import ./overlays; # nixpkgs overlays
example-package = pkgs.callPackage ./pkgs/example-package { };
- # some-qt5-package = pkgs.libsForQt5.callPackage ./pkgs/some-qt5-package { };
- # ...
+ hgrep = pkgs.callPackage ./pkgs/hgrep { };
+
+ git-helpers = pkgs.callPackage ./pkgs/git-helpers { };
+ reparojson = pkgs.callPackage ./pkgs/reparojson { };
+ term-banner = pkgs.callPackage ./pkgs/term-banner { };
+ term-clock = pkgs.callPackage ./pkgs/term-clock { };
}
diff --git a/flake.lock b/flake.lock
index 78cf35d..93684c4 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
- "lastModified": 1712449641,
- "narHash": "sha256-U9DDWMexN6o5Td2DznEgguh8TRIUnIl9levmit43GcI=",
+ "lastModified": 1745377448,
+ "narHash": "sha256-jhZDfXVKdD7TSEGgzFJQvEEZ2K65UMiqW5YJ2aIqxMA=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "600b15aea1b36eeb43833a50b0e96579147099ff",
+ "rev": "507b63021ada5fee621b6ca371c4fca9ca46f52c",
"type": "github"
},
"original": {
@@ -18,7 +18,28 @@
},
"root": {
"inputs": {
- "nixpkgs": "nixpkgs"
+ "nixpkgs": "nixpkgs",
+ "treefmt-nix": "treefmt-nix"
+ }
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1744961264,
+ "narHash": "sha256-aRmUh0AMwcbdjJHnytg1e5h5ECcaWtIFQa6d9gI85AI=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "8d404a69efe76146368885110f29a2ca3700bee6",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
}
}
},
diff --git a/flake.nix b/flake.nix
index c47487a..a9fd7ea 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,14 +1,41 @@
{
description = "My personal NUR repository";
- inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
- outputs = { self, nixpkgs }:
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+
+ treefmt-nix = {
+ url = "github:numtide/treefmt-nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ outputs =
+ {
+ self,
+ nixpkgs,
+ treefmt-nix,
+ }:
let
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
in
{
- legacyPackages = forAllSystems (system: import ./default.nix {
- pkgs = import nixpkgs { inherit system; };
- });
- packages = forAllSystems (system: nixpkgs.lib.filterAttrs (_: v: nixpkgs.lib.isDerivation v) self.legacyPackages.${system});
+ formatter = forAllSystems (
+ system:
+ let
+ pkgs = import nixpkgs { inherit system; };
+ treefmt = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
+ in
+ treefmt.config.build.wrapper
+ );
+ legacyPackages = forAllSystems (
+ system:
+ import ./default.nix {
+ pkgs = import nixpkgs { inherit system; };
+ }
+ );
+ packages = forAllSystems (
+ system: nixpkgs.lib.filterAttrs (_: v: nixpkgs.lib.isDerivation v) self.legacyPackages.${system}
+ );
};
}
diff --git a/lib/default.nix b/lib/default.nix
index a7fab1d..1d25545 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -1,6 +1,7 @@
{ pkgs }:
-with pkgs.lib; {
+with pkgs.lib;
+{
# Add your library functions here
#
# hexint = x: hexvals.${toLower x};
diff --git a/overlay.nix b/overlay.nix
index bff7396..4272d50 100644
--- a/overlay.nix
+++ b/overlay.nix
@@ -5,11 +5,15 @@
self: super:
let
isReserved = n: n == "lib" || n == "overlays" || n == "modules";
- nameValuePair = n: v: { name = n; value = v; };
+ 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)))
+builtins.listToAttrs (
+ map (n: nameValuePair n nurAttrs.${n}) (
+ builtins.filter (n: !isReserved n) (builtins.attrNames nurAttrs)
+ )
+)
diff --git a/pkgs/git-helpers/default.nix b/pkgs/git-helpers/default.nix
new file mode 100644
index 0000000..94b4121
--- /dev/null
+++ b/pkgs/git-helpers/default.nix
@@ -0,0 +1,24 @@
+{
+ lib,
+ buildGoModule,
+ fetchFromGitHub,
+}:
+
+buildGoModule rec {
+ pname = "git-helpers";
+ version = "0.1.0";
+
+ src = fetchFromGitHub {
+ owner = "nsfisis";
+ repo = "git-helpers";
+ rev = "v${version}";
+ hash = "sha256-iK3P91PwKgQz4WIQBJVGjDP65dZSB0LL/NGItMj/wzQ=";
+ };
+ vendorHash = null;
+
+ meta = {
+ description = "My git helpers";
+ homepage = "https://github.com/nsfisis/git-helpers";
+ license = lib.licenses.mit;
+ };
+}
diff --git a/pkgs/hgrep/default.nix b/pkgs/hgrep/default.nix
new file mode 100644
index 0000000..004041e
--- /dev/null
+++ b/pkgs/hgrep/default.nix
@@ -0,0 +1,56 @@
+{
+ lib,
+ rustPlatform,
+ fetchFromGitHub,
+ installShellFiles,
+}:
+
+rustPlatform.buildRustPackage rec {
+ pname = "hgrep";
+ version = "0.3.8";
+
+ src = fetchFromGitHub {
+ owner = "rhysd";
+ repo = "hgrep";
+ rev = "v${version}";
+ hash = "sha256-GcV6tZLhAtBE0/husOqZ3Gib9nXXg7kcxrNp9IK0eTo=";
+ };
+ cargoHash = "sha256-NxfWY9OoMNASlWE48njuAdTI11JAV+rzjD0OU2cHLsc=";
+
+ nativeBuildInputs = [
+ installShellFiles
+ ];
+
+ # Disable bat-printer because I won't use it.
+ # https://github.com/rhysd/hgrep/blob/v0.3.8/Cargo.toml#L44-L48
+ buildNoDefaultFeatures = true;
+ buildFeatures = [
+ "ripgrep"
+ # "bat-printer"
+ "syntect-printer"
+ ];
+
+ checkFlags = [
+ # Disable snapshot tests.
+ "--skip=tests::arg_matches"
+ ];
+
+ postFixup = ''
+ $out/bin/hgrep --generate-man-page > hgrep.1
+ installManPage hgrep.1
+
+ installShellCompletion --cmd hgrep \
+ --bash <($out/bin/hgrep --generate-completion-script bash) \
+ --zsh <($out/bin/hgrep --generate-completion-script zsh) \
+ --fish <($out/bin/hgrep --generate-completion-script fish) \
+ ;
+ '';
+
+ meta = {
+ description = "hgrep is a grep tool with human-friendly search output. This is similar to `-C` option of `grep` command, but its output is enhanced with syntax highlighting focusing on human readable outputs.";
+ homepage = "https://github.com/rhysd/hgrep";
+ changelog = "https://github.com/rhysd/hgrep/raw/v${version}/CHANGELOG.md";
+ license = lib.licenses.mit;
+ mainProgram = "hgrep";
+ };
+}
diff --git a/pkgs/reparojson/default.nix b/pkgs/reparojson/default.nix
new file mode 100644
index 0000000..3402593
--- /dev/null
+++ b/pkgs/reparojson/default.nix
@@ -0,0 +1,25 @@
+{
+ lib,
+ rustPlatform,
+ fetchFromGitHub,
+}:
+
+rustPlatform.buildRustPackage rec {
+ pname = "reparojson";
+ version = "0.1.2";
+
+ src = fetchFromGitHub {
+ owner = "nsfisis";
+ repo = "reparojson";
+ rev = "v${version}";
+ hash = "sha256-kex4LNS7yT8BbaNE/uZrGED8Rx2QmPgCgPwBnIO2za8=";
+ };
+ cargoHash = "sha256-nFv22XP5bhS++li21VsB4aMJ3q5veH6zsK9cCNTVz0k=";
+
+ meta = {
+ description = "A simple command-line tool to repair JSON. It only fixes the syntactic errors and never formats the given input.";
+ homepage = "https://github.com/nsfisis/reparojson";
+ license = lib.licenses.mit;
+ mainProgram = "reparojson";
+ };
+}
diff --git a/pkgs/term-banner/default.nix b/pkgs/term-banner/default.nix
new file mode 100644
index 0000000..37ab1a5
--- /dev/null
+++ b/pkgs/term-banner/default.nix
@@ -0,0 +1,25 @@
+{
+ lib,
+ buildGoModule,
+ fetchFromGitHub,
+}:
+
+buildGoModule rec {
+ pname = "term-banner";
+ version = "1.2.0";
+
+ src = fetchFromGitHub {
+ owner = "nsfisis";
+ repo = "term-banner";
+ rev = "v${version}";
+ hash = "sha256-YCIT+6PdHLrOrPzWpF/U8G8qGcYDXkgVMde/IUWRe84=";
+ };
+ vendorHash = "sha256-i78RKipeirkmteFsYmmmu0gU4cjph01gn/9zl8lcpXM=";
+
+ meta = {
+ description = "Show a banner in your terminal.";
+ homepage = "https://github.com/nsfisis/term-banner";
+ license = lib.licenses.mit;
+ mainProgram = "term-banner";
+ };
+}
diff --git a/pkgs/term-clock/default.nix b/pkgs/term-clock/default.nix
new file mode 100644
index 0000000..ce507fe
--- /dev/null
+++ b/pkgs/term-clock/default.nix
@@ -0,0 +1,38 @@
+{
+ lib,
+ buildGoModule,
+ fetchFromGitHub,
+ installShellFiles,
+}:
+
+buildGoModule rec {
+ pname = "term-clock";
+ version = "1.0.0";
+
+ src = fetchFromGitHub {
+ owner = "nsfisis";
+ repo = "term-clock";
+ rev = "v${version}";
+ hash = "sha256-IB6AFQpbTVfDbEbTnq4sWTxKHAoNQlmw5tvBl13y4yc=";
+ };
+ vendorHash = "sha256-NLxaPtxhb67uhs01DASlAIfCIWV1lnuiu+uFmJcxN0U=";
+
+ nativeBuildInputs = [
+ installShellFiles
+ ];
+
+ postFixup = ''
+ installShellCompletion --cmd term-clock \
+ --bash <($out/bin/term-clock completion bash) \
+ --zsh <($out/bin/term-clock completion zsh) \
+ --fish <($out/bin/term-clock completion fish) \
+ ;
+ '';
+
+ meta = {
+ description = "A clock on your terminal";
+ homepage = "https://github.com/nsfisis/term-clock";
+ license = lib.licenses.mit;
+ mainProgram = "term-clock";
+ };
+}
diff --git a/treefmt.nix b/treefmt.nix
new file mode 100644
index 0000000..972a362
--- /dev/null
+++ b/treefmt.nix
@@ -0,0 +1,5 @@
+{ pkgs, ... }:
+{
+ projectRootFile = "flake.nix";
+ programs.nixfmt.enable = true;
+}