treewide: reformat nixfmt-rfc-style
Reformat repository using new nixfmt-rfc-style.
This commit is contained in:
parent
5df48c4255
commit
cba2f9ce95
1051 changed files with 37028 additions and 26594 deletions
|
|
@ -2,46 +2,70 @@
|
|||
# file is considered internal and the exported fields may change without
|
||||
# warning.
|
||||
|
||||
{ newsJsonFile, newsReadIdsFile ? null }:
|
||||
{
|
||||
newsJsonFile,
|
||||
newsReadIdsFile ? null,
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (builtins)
|
||||
concatStringsSep filter hasAttr isString length readFile replaceStrings sort
|
||||
split;
|
||||
concatStringsSep
|
||||
filter
|
||||
hasAttr
|
||||
isString
|
||||
length
|
||||
readFile
|
||||
replaceStrings
|
||||
sort
|
||||
split
|
||||
;
|
||||
|
||||
newsJson = builtins.fromJSON (builtins.readFile newsJsonFile);
|
||||
|
||||
# Sorted and relevant entries.
|
||||
relevantEntries =
|
||||
sort (a: b: a.time > b.time) (filter (e: e.condition) newsJson.entries);
|
||||
relevantEntries = sort (a: b: a.time > b.time) (filter (e: e.condition) newsJson.entries);
|
||||
|
||||
newsReadIds = if newsReadIdsFile == null then
|
||||
{ }
|
||||
else
|
||||
let ids = filter isString (split "\n" (readFile newsReadIdsFile));
|
||||
in builtins.listToAttrs (map (id: {
|
||||
name = id;
|
||||
value = null;
|
||||
}) ids);
|
||||
newsReadIds =
|
||||
if newsReadIdsFile == null then
|
||||
{ }
|
||||
else
|
||||
let
|
||||
ids = filter isString (split "\n" (readFile newsReadIdsFile));
|
||||
in
|
||||
builtins.listToAttrs (
|
||||
map (id: {
|
||||
name = id;
|
||||
value = null;
|
||||
}) ids
|
||||
);
|
||||
|
||||
newsIsRead = entry: hasAttr entry.id newsReadIds;
|
||||
|
||||
newsUnread = let pred = entry: entry.condition && !newsIsRead entry;
|
||||
in filter pred relevantEntries;
|
||||
newsUnread =
|
||||
let
|
||||
pred = entry: entry.condition && !newsIsRead entry;
|
||||
in
|
||||
filter pred relevantEntries;
|
||||
|
||||
prettyTime = t: replaceStrings [ "T" "+00:00" ] [ " " "" ] t;
|
||||
|
||||
layoutNews = entries:
|
||||
layoutNews =
|
||||
entries:
|
||||
let
|
||||
mkTextEntry = entry:
|
||||
let flag = if newsIsRead entry then "read" else "unread";
|
||||
in ''
|
||||
mkTextEntry =
|
||||
entry:
|
||||
let
|
||||
flag = if newsIsRead entry then "read" else "unread";
|
||||
in
|
||||
''
|
||||
* ${prettyTime entry.time} [${flag}]
|
||||
|
||||
${replaceStrings [ "\n" ] [ "\n " ] entry.message}
|
||||
'';
|
||||
in concatStringsSep "\n\n" (map mkTextEntry entries);
|
||||
in {
|
||||
in
|
||||
concatStringsSep "\n\n" (map mkTextEntry entries);
|
||||
in
|
||||
{
|
||||
meta = {
|
||||
numUnread = length newsUnread;
|
||||
display = newsJson.display;
|
||||
|
|
|
|||
|
|
@ -1,64 +1,79 @@
|
|||
{ runCommand, lib, bash, callPackage, coreutils, findutils, gettext, gnused, jq
|
||||
, less, ncurses, inetutils
|
||||
# used for pkgs.path for nixos-option
|
||||
, pkgs
|
||||
{
|
||||
runCommand,
|
||||
lib,
|
||||
bash,
|
||||
callPackage,
|
||||
coreutils,
|
||||
findutils,
|
||||
gettext,
|
||||
gnused,
|
||||
jq,
|
||||
less,
|
||||
ncurses,
|
||||
inetutils,
|
||||
# used for pkgs.path for nixos-option
|
||||
pkgs,
|
||||
|
||||
# Path to use as the Home Manager channel.
|
||||
, path ? null }:
|
||||
# Path to use as the Home Manager channel.
|
||||
path ? null,
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
pathStr = if path == null then "" else path;
|
||||
|
||||
nixos-option = pkgs.nixos-option or (callPackage
|
||||
(pkgs.path + "/nixos/modules/installer/tools/nixos-option") { });
|
||||
nixos-option =
|
||||
pkgs.nixos-option or (callPackage (pkgs.path + "/nixos/modules/installer/tools/nixos-option") { });
|
||||
|
||||
in runCommand "home-manager" {
|
||||
preferLocalBuild = true;
|
||||
nativeBuildInputs = [ gettext ];
|
||||
meta = {
|
||||
mainProgram = "home-manager";
|
||||
description = "A user environment configurator";
|
||||
maintainers = [ lib.maintainers.rycee ];
|
||||
platforms = lib.platforms.unix;
|
||||
license = lib.licenses.mit;
|
||||
};
|
||||
} ''
|
||||
install -v -D -m755 ${./home-manager} $out/bin/home-manager
|
||||
in
|
||||
runCommand "home-manager"
|
||||
{
|
||||
preferLocalBuild = true;
|
||||
nativeBuildInputs = [ gettext ];
|
||||
meta = {
|
||||
mainProgram = "home-manager";
|
||||
description = "A user environment configurator";
|
||||
maintainers = [ lib.maintainers.rycee ];
|
||||
platforms = lib.platforms.unix;
|
||||
license = lib.licenses.mit;
|
||||
};
|
||||
}
|
||||
''
|
||||
install -v -D -m755 ${./home-manager} $out/bin/home-manager
|
||||
|
||||
substituteInPlace $out/bin/home-manager \
|
||||
--subst-var-by bash "${bash}" \
|
||||
--subst-var-by DEP_PATH "${
|
||||
lib.makeBinPath [
|
||||
coreutils
|
||||
findutils
|
||||
gettext
|
||||
gnused
|
||||
jq
|
||||
less
|
||||
ncurses
|
||||
nixos-option
|
||||
inetutils # for `hostname`
|
||||
]
|
||||
}" \
|
||||
--subst-var-by HOME_MANAGER_LIB '${../lib/bash/home-manager.sh}' \
|
||||
--subst-var-by HOME_MANAGER_PATH '${pathStr}' \
|
||||
--subst-var-by OUT "$out"
|
||||
substituteInPlace $out/bin/home-manager \
|
||||
--subst-var-by bash "${bash}" \
|
||||
--subst-var-by DEP_PATH "${
|
||||
lib.makeBinPath [
|
||||
coreutils
|
||||
findutils
|
||||
gettext
|
||||
gnused
|
||||
jq
|
||||
less
|
||||
ncurses
|
||||
nixos-option
|
||||
inetutils # for `hostname`
|
||||
]
|
||||
}" \
|
||||
--subst-var-by HOME_MANAGER_LIB '${../lib/bash/home-manager.sh}' \
|
||||
--subst-var-by HOME_MANAGER_PATH '${pathStr}' \
|
||||
--subst-var-by OUT "$out"
|
||||
|
||||
install -D -m755 ${./completion.bash} \
|
||||
$out/share/bash-completion/completions/home-manager
|
||||
install -D -m755 ${./completion.zsh} \
|
||||
$out/share/zsh/site-functions/_home-manager
|
||||
install -D -m755 ${./completion.fish} \
|
||||
$out/share/fish/vendor_completions.d/home-manager.fish
|
||||
install -D -m755 ${./completion.bash} \
|
||||
$out/share/bash-completion/completions/home-manager
|
||||
install -D -m755 ${./completion.zsh} \
|
||||
$out/share/zsh/site-functions/_home-manager
|
||||
install -D -m755 ${./completion.fish} \
|
||||
$out/share/fish/vendor_completions.d/home-manager.fish
|
||||
|
||||
install -D -m755 ${../lib/bash/home-manager.sh} \
|
||||
"$out/share/bash/home-manager.sh"
|
||||
install -D -m755 ${../lib/bash/home-manager.sh} \
|
||||
"$out/share/bash/home-manager.sh"
|
||||
|
||||
for path in ${./po}/*.po; do
|
||||
lang="''${path##*/}"
|
||||
lang="''${lang%%.*}"
|
||||
mkdir -p "$out/share/locale/$lang/LC_MESSAGES"
|
||||
msgfmt -o "$out/share/locale/$lang/LC_MESSAGES/home-manager.mo" "$path"
|
||||
done
|
||||
''
|
||||
for path in ${./po}/*.po; do
|
||||
lang="''${path##*/}"
|
||||
lang="''${lang%%.*}"
|
||||
mkdir -p "$out/share/locale/$lang/LC_MESSAGES"
|
||||
msgfmt -o "$out/share/locale/$lang/LC_MESSAGES/home-manager.mo" "$path"
|
||||
done
|
||||
''
|
||||
|
|
|
|||
|
|
@ -1,18 +1,31 @@
|
|||
{ pkgs ? import <nixpkgs> { }, confPath, confAttr ? null, check ? true
|
||||
, newsReadIdsFile ? null }:
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
confPath,
|
||||
confAttr ? null,
|
||||
check ? true,
|
||||
newsReadIdsFile ? null,
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (pkgs.lib)
|
||||
concatMapStringsSep fileContents filter length optionalString removeSuffix
|
||||
replaceStrings splitString;
|
||||
concatMapStringsSep
|
||||
fileContents
|
||||
filter
|
||||
length
|
||||
optionalString
|
||||
removeSuffix
|
||||
replaceStrings
|
||||
splitString
|
||||
;
|
||||
|
||||
env = import ../modules {
|
||||
configuration = if confAttr == "" || confAttr == null then
|
||||
confPath
|
||||
else
|
||||
(import confPath).${confAttr};
|
||||
configuration =
|
||||
if confAttr == "" || confAttr == null then confPath else (import confPath).${confAttr};
|
||||
pkgs = pkgs;
|
||||
check = check;
|
||||
};
|
||||
|
||||
in { inherit (env) activationPackage config; }
|
||||
in
|
||||
{
|
||||
inherit (env) activationPackage config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,16 @@ let
|
|||
source ${home-manager}/share/bash/home-manager.sh
|
||||
'';
|
||||
|
||||
in runCommand "home-manager-install" {
|
||||
propagatedBuildInputs = [ home-manager ];
|
||||
preferLocalBuild = true;
|
||||
shellHookOnly = true;
|
||||
shellHook = "exec ${home-manager}/bin/home-manager init --switch --no-flake";
|
||||
} ''
|
||||
${hmBashLibInit}
|
||||
_iError 'This derivation is not buildable, please run it using nix-shell.'
|
||||
exit 1
|
||||
''
|
||||
in
|
||||
runCommand "home-manager-install"
|
||||
{
|
||||
propagatedBuildInputs = [ home-manager ];
|
||||
preferLocalBuild = true;
|
||||
shellHookOnly = true;
|
||||
shellHook = "exec ${home-manager}/bin/home-manager init --switch --no-flake";
|
||||
}
|
||||
''
|
||||
${hmBashLibInit}
|
||||
_iError 'This derivation is not buildable, please run it using nix-shell.'
|
||||
exit 1
|
||||
''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue