Flake
This commit is contained in:
parent
d45b12a9f6
commit
3f3cd0c357
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
result
|
53
flake.lock
53
flake.lock
|
@ -1,24 +1,59 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1627805549,
|
||||
"narHash": "sha256-+LHhcpzw6vAxF6q0VSLkZSEGpDC02JN21KM8eUWz+is=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "16bf3980bfa0d8929639be93fa8491ebad9d61ec",
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-21.05",
|
||||
"type": "indirect"
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1697655685,
|
||||
"narHash": "sha256-79Kuv+QdgsVc+rkibuAgWHnh8IXrLBTOKg5nM0Qvux0=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "80c1aab725151632ddc2a20caeb914e76dd0673c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-23.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
138
flake.nix
138
flake.nix
|
@ -1,118 +1,38 @@
|
|||
{
|
||||
description = "An over-engineered Hello World in bash";
|
||||
{ description = "A few random scripts";
|
||||
inputs = {
|
||||
nixpkgs.url = github:nixos/nixpkgs/nixos-23.05;
|
||||
flake-utils.url = github:numtide/flake-utils;
|
||||
};
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem ( system:
|
||||
let pkgs = import nixpkgs { inherit system; };
|
||||
in{
|
||||
packages = rec {
|
||||
default = pkgs.stdenvNoCC.mkDerivation rec {
|
||||
pname = "irs";
|
||||
version = "0.1";
|
||||
|
||||
# Nixpkgs / NixOS version to use.
|
||||
inputs.nixpkgs.url = "nixpkgs/nixos-21.05";
|
||||
src = ./src;
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
buildInputs = with pkgs; [
|
||||
coreutils
|
||||
scdoc
|
||||
];
|
||||
|
||||
# to work with older version of flakes
|
||||
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
|
||||
buildPhase = ''
|
||||
|
||||
# Generate a user-friendly version number.
|
||||
version = builtins.substring 0 8 lastModifiedDate;
|
||||
for page in $(find manpages -type f); do
|
||||
scdoc < $page > $(basename $page .scd)
|
||||
done
|
||||
|
||||
# System types to support.
|
||||
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||
|
||||
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||
|
||||
# Nixpkgs instantiated for supported system types.
|
||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
# A Nixpkgs overlay.
|
||||
overlay = final: prev: {
|
||||
|
||||
hello = with final; stdenv.mkDerivation rec {
|
||||
name = "hello-${version}";
|
||||
|
||||
unpackPhase = ":";
|
||||
|
||||
installPhase =
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
cp hello $out/bin/
|
||||
'';
|
||||
};
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/{share/man/man1,bin}
|
||||
cp bin/* $out/bin/
|
||||
cp *.1 $out/share/man/man1
|
||||
'';
|
||||
};
|
||||
|
||||
# Provide some binary packages for selected system types.
|
||||
packages = forAllSystems (system:
|
||||
{
|
||||
inherit (nixpkgsFor.${system}) hello;
|
||||
});
|
||||
|
||||
# The default package for 'nix build'. This makes sense if the
|
||||
# flake provides only one package or there is a clear "main"
|
||||
# package.
|
||||
defaultPackage = forAllSystems (system: self.packages.${system}.hello);
|
||||
|
||||
# A NixOS module, if applicable (e.g. if the package provides a system service).
|
||||
nixosModules.hello =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
nixpkgs.overlays = [ self.overlay ];
|
||||
|
||||
environment.systemPackages = [ pkgs.hello ];
|
||||
|
||||
#systemd.services = { ... };
|
||||
};
|
||||
|
||||
# Tests run by 'nix flake check' and by Hydra.
|
||||
checks = forAllSystems
|
||||
(system:
|
||||
with nixpkgsFor.${system};
|
||||
|
||||
{
|
||||
inherit (self.packages.${system}) hello;
|
||||
|
||||
# Additional tests, if applicable.
|
||||
test = stdenv.mkDerivation {
|
||||
name = "hello-test-${version}";
|
||||
|
||||
buildInputs = [ hello ];
|
||||
|
||||
unpackPhase = "true";
|
||||
|
||||
buildPhase = ''
|
||||
echo 'running some integration tests'
|
||||
[[ $(hello) = 'Hello Nixers!' ]]
|
||||
'';
|
||||
|
||||
installPhase = "mkdir -p $out";
|
||||
};
|
||||
}
|
||||
|
||||
// lib.optionalAttrs stdenv.isLinux {
|
||||
# A VM test of the NixOS module.
|
||||
vmTest =
|
||||
with import (nixpkgs + "/nixos/lib/testing-python.nix") {
|
||||
inherit system;
|
||||
};
|
||||
|
||||
makeTest {
|
||||
nodes = {
|
||||
client = { ... }: {
|
||||
imports = [ self.nixosModules.hello ];
|
||||
};
|
||||
};
|
||||
|
||||
testScript =
|
||||
''
|
||||
start_all()
|
||||
client.wait_for_unit("multi-user.target")
|
||||
client.succeed("hello")
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#!/bin/sh
|
||||
bookmarks="${BOOKMARKS:-"$HOME/.config/qutebrowser/bookmarks/urls"}"
|
||||
menu="${MENU:-"rofi -dmenu"}"
|
||||
|
||||
choice="$(sort $bookmarks | $menu -i -p "Bookmarks")"
|
||||
xdg-open "$(echo "$choice" | awk '{print$1}')"
|
20
src/bin/open-bookmark
Executable file
20
src/bin/open-bookmark
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
usage(){
|
||||
printf "Usage: %s: -s|f|r|d|h\n" $0
|
||||
}
|
||||
|
||||
bookmarks="${BOOKMARKS:-"$HOME/.config/qutebrowser/bookmarks/urls"}"
|
||||
while getopts sfrdh name; do
|
||||
case $name in
|
||||
f) menu="fzf";;
|
||||
r) menu="rofi -dmenu -i -p 'Bookmarks'";;
|
||||
s) menu="sk";;
|
||||
d) menu="${MENU}";;
|
||||
h) usage ;;
|
||||
*) usage
|
||||
exit 2;;
|
||||
esac
|
||||
done
|
||||
choice="$(sort $bookmarks | $menu )"
|
||||
[ -z "$choice" ] || xdg-open "$(echo "$choice" | awk '{print$1}')"
|
11
src/bin/se
Executable file
11
src/bin/se
Executable file
|
@ -0,0 +1,11 @@
|
|||
#! /bin/sh
|
||||
if [ $# -eq 1 ] ; then
|
||||
case $1 in
|
||||
--help) echo "Opens a script in vim either as an argument or from the ~/.local/bin directory using skim";;
|
||||
-h) echo "Opens a script in vim either as an argument or from the ~/.local/bin directory using skim";;
|
||||
*) $EDITOR $(which $1);;
|
||||
esac
|
||||
else
|
||||
script=$(find ~/.local/bin -type f | sk --preview 'cat {}')
|
||||
[ "$script" != "" ] && nvim $script || exit 0
|
||||
fi
|
27
src/manpages/irs.1.scd
Normal file
27
src/manpages/irs.1.scd
Normal file
|
@ -0,0 +1,27 @@
|
|||
se(1)
|
||||
|
||||
# NAME
|
||||
|
||||
*irs* - because -- and I quote: "Random collection of scripts. The IRS collects
|
||||
taxes. You send a wrong amount of taxes, they randomly send you to jail."
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
This package has a few scripts that I used to keep in my '*~/.local/bin*'
|
||||
directory, but that didn't work well with the Nix ethos and it got rather
|
||||
annoying to move them between systems. Here's a badly put together solution to
|
||||
both problems.
|
||||
|
||||
# SCRIPTS
|
||||
|
||||
*se*
|
||||
short for 'script edit'; when not given any arguments opens '*~/.local/bin*'
|
||||
in *sk(1)* and allows you to make a seletion of what item in there using
|
||||
*$EDITOR*
|
||||
|
||||
*open-bookmark*
|
||||
opens a bookmark in *xdg-open(1)*, see its own manpage for more information
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
*open-bookmark(1)*, *xdg-open(1)*
|
29
src/manpages/open-bookmark.1.scd
Normal file
29
src/manpages/open-bookmark.1.scd
Normal file
|
@ -0,0 +1,29 @@
|
|||
open-bookmark(1)
|
||||
|
||||
# NAME
|
||||
|
||||
*open-bookmark* - opens a *qutebrowser(1)* bookmark using *xdg-open(1)*
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
*open-bookmark -s|f|r|d|h*
|
||||
|
||||
# OPTIONS
|
||||
|
||||
*-s*
|
||||
use *sk(1)* to open *qutebrowser(1)* bookmarks file
|
||||
|
||||
*-f*
|
||||
use *fzf(1)* to open *qutebrowser(1)* bookmarks file
|
||||
|
||||
*-r*
|
||||
use *rofi(1)* to open *qutebrowser(1)* bookmarks file
|
||||
|
||||
*-d*
|
||||
use *$MENU* to open *qutebrowser(1)* bookmarks file
|
||||
|
||||
*-h*
|
||||
print usage and exit
|
||||
|
||||
# SEE ALSO
|
||||
*fzf(1)*, *sk(1)*, *rofi(1)*, *qutebrowser(1)*
|
Loading…
Reference in a new issue