change flakes, fix typos in readme

This commit is contained in:
Dmitriy Kholkin 2021-09-27 22:35:31 +03:00
parent 462f0033e6
commit 862a55eb25
Signed by: AtaraxiaDev
GPG Key ID: FD266B810DF48DF2
3 changed files with 80 additions and 47 deletions

View File

@ -14,7 +14,7 @@ Differences:
import this flake in your 'flake.nix':
```nix
inputs.base16.url = 'github:alukardbf/base16-nix';
inputs.base16.url = "github:alukardbf/base16-nix";
```
then, in any home-manager configuration:
@ -22,8 +22,7 @@ then, in any home-manager configuration:
```nix
home.user.${user} = { config, pkgs, lib }: {
imports = [ base16.hmModule ];
}
};
```
```nix
@ -48,11 +47,11 @@ home.user.${user} = { config, pkgs, lib }: {
###############################
programs.bash.initExtra = ''
source ${config.lib.base16.templateFile { name = "shell"; };}
source ${config.lib.base16.templateFile { name = "shell"; }}
'';
programs.rofi = {
enable = true;
theme = "${config.lib.base16.templateFile { name = "rofi"; type = "color"; };}";
theme = "${config.lib.base16.templateFile { name = "rofi"; type = "colors"; }}";
};
# 2. Template strings directly into other home-manager configuration
@ -103,7 +102,7 @@ You can also use local schemes:
customScheme = {
enable = true;
path = ./base16-custom-scheme.yaml;
}
};
};
};
}
@ -130,13 +129,13 @@ inputs.base16-horizon-scheme = {
customScheme = {
enable = true;
path = "${inputs.base16-horizon-scheme}/horizon-dark.yaml";
}
};
};
# The template will be generated from the local scheme
programs.rofi = {
enable = true;
theme = "${config.lib.base16.templateFile { name = "rofi"; };}";
theme = "${config.lib.base16.templateFile { name = "rofi"; }}";
};
};
}
@ -146,20 +145,21 @@ inputs.base16-horizon-scheme = {
Changing themes involves switching the theme definition and typing
`home-manager switch`. There is no attempt in general to force programs to
reload, and not all are able to reload their configs, although I have found
that reloading xmonad and occasionally restarting applications has been
enough.
reload, and not all are able to reload their configs, although occasionally restarting applications has been enough.
You are unlikely to achieve a complete switch without logging out and logging back
in again.
Also, if you use home-manager as a module in the system configuration, the switch should be done with the command `nixos-rebuild switch`.
## Updating Sources
If you're using nix flakes:
- Fork this repository
- `cd` into repository dir
- Enter `nix develop` and then run `update-base16`
- Enter `nix develop` and then run `update-base16` OR
- Enter `nix run .`
- Commit and push new files
If you're **not** using nix flakes:

16
flake.lock generated
View File

@ -1,5 +1,20 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1631561581,
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1623798125,
@ -17,6 +32,7 @@
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}

View File

@ -2,43 +2,60 @@
description = "Base16-template builder for nix.";
inputs.nixpkgs.url = "nixpkgs/release-21.05";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = inputs@{ self, nixpkgs }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in {
outputs = { self, nixpkgs, flake-utils }@inputs:
flake-utils.lib.eachDefaultSystem
(system:
with nixpkgs.legacyPackages.${system};
{
# Home-Manager Module
hmModule = ./base16.nix;
# Home-Manager Module
hmModule = ./base16.nix;
packages.update-base16 = (let
mkScript = { name, file, env ? [ ] }:
writeTextFile {
name = "${name}";
executable = true;
destination = "/bin/${name}";
text = ''
for i in ${lib.concatStringsSep " " env}; do
export PATH="$i/bin:$PATH"
done
exec ${bash}/bin/bash ${file} $@
'';
};
in mkScript rec {
name = "update-base16";
env = [ curl nix-prefetch-git gnused jq ];
file = writeTextFile {
name = "${name}.sh";
executable = true;
text = ''
generate_sources () {
out=$1
curl "https://raw.githubusercontent.com/chriskempson/base16-$out-source/master/list.yaml"\
| sed -nE "s~^([-_[:alnum:]]+): *(.*)~\1 \2~p"\
| while read name src; do
echo "{\"key\":\"$name\",\"value\":"
nix-prefetch-git $src
echo "}"
done\
| jq -s ".|del(.[].value.date)|from_entries"\
> $out.json
}
generate_sources templates &
generate_sources schemes &
wait
'';
};
});
# Nix shell definition. Enter with 'nix develop'. Inside, can use
# 'update-base16' to update the sources lists.
devShell.x86_64-linux = let
update = pkgs.writeShellScriptBin "update-base16" ''
# should always be permitted to run to completion
generate_sources () {
out=$1
curl "https://raw.githubusercontent.com/chriskempson/base16-$out-source/master/list.yaml"\
| sed -nE "s~^([-_[:alnum:]]+): *(.*)~\1 \2~p"\
| while read name src; do
echo "{\"key\":\"$name\",\"value\":"
nix-prefetch-git $src
echo "}"
done\
| jq -s ".|del(.[].value.date)|from_entries"\
> $out.json
}
generate_sources templates &
generate_sources schemes &
wait
'';
in pkgs.mkShell {
nativeBuildInputs = with pkgs; [
curl nix-prefetch-git gnused jq update
];
};
};
defaultPackage = packages.update-base16;
devShell = mkShell {
buildInputs = [ packages.update-base16 ];
};
}
);
}