1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

format: update and remove exceptions (#3029)

Switches to nixfmt 0.5.0 and removes exceptions for files without open
PRs.
This commit is contained in:
Naïm Camille Favier 2022-06-16 14:13:06 +02:00 committed by GitHub
parent 504d6de6a0
commit 1de492f6f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 67 deletions

5
format
View file

@ -1,5 +1,5 @@
#! /usr/bin/env nix-shell #! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/5edf5b60c3d8f82b5fc5e73e822b6f7460584945.tar.gz -i bash -p findutils nixfmt #! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/6616de389ed55fba6eeba60377fc04732d5a207c.tar.gz -i bash -p findutils nixfmt
CHECK_ARG= CHECK_ARG=
@ -15,14 +15,11 @@ esac
# The excludes are for files touched by open pull requests and we want # The excludes are for files touched by open pull requests and we want
# to avoid merge conflicts. # to avoid merge conflicts.
find . -name '*.nix' \ find . -name '*.nix' \
! -path ./home-manager/home-manager.nix \
! -path ./modules/default.nix \ ! -path ./modules/default.nix \
! -path ./modules/files.nix \ ! -path ./modules/files.nix \
! -path ./modules/home-environment.nix \ ! -path ./modules/home-environment.nix \
! -path ./modules/launchd/launchd.nix \
! -path ./modules/lib/default.nix \ ! -path ./modules/lib/default.nix \
! -path ./modules/lib/file-type.nix \ ! -path ./modules/lib/file-type.nix \
! -path ./modules/manual.nix \
! -path ./modules/misc/news.nix \ ! -path ./modules/misc/news.nix \
! -path ./modules/programs/bash.nix \ ! -path ./modules/programs/bash.nix \
! -path ./modules/programs/ssh.nix \ ! -path ./modules/programs/ssh.nix \

View file

@ -1,9 +1,5 @@
{ pkgs ? import <nixpkgs> {} { pkgs ? import <nixpkgs> { }, confPath, confAttr ? null, check ? true
, confPath , newsReadIdsFile ? null }:
, confAttr ? null
, check ? true
, newsReadIdsFile ? null
}:
let let
inherit (pkgs.lib) inherit (pkgs.lib)
@ -11,68 +7,58 @@ let
replaceStrings splitString; replaceStrings splitString;
env = import ../modules { env = import ../modules {
configuration = configuration = if confAttr == "" || confAttr == null then
if confAttr == "" || confAttr == null confPath
then confPath else
else (import confPath).${confAttr}; (import confPath).${confAttr};
pkgs = pkgs; pkgs = pkgs;
check = check; check = check;
}; };
newsReadIds = newsReadIds = if newsReadIdsFile == null then
if newsReadIdsFile == null { }
then {}
else else
let let ids = splitString "\n" (fileContents newsReadIdsFile);
ids = splitString "\n" (fileContents newsReadIdsFile); in builtins.listToAttrs (map (id: {
in name = id;
builtins.listToAttrs (map (id: { name = id; value = null; }) ids); value = null;
}) ids);
newsIsRead = entry: builtins.hasAttr entry.id newsReadIds; newsIsRead = entry: builtins.hasAttr entry.id newsReadIds;
newsFiltered = newsFiltered = let pred = entry: entry.condition && !newsIsRead entry;
let in filter pred env.newsEntries;
pred = entry: entry.condition && ! newsIsRead entry;
in
filter pred env.newsEntries;
newsNumUnread = length newsFiltered; newsNumUnread = length newsFiltered;
newsFileUnread = pkgs.writeText "news-unread.txt" ( newsFileUnread = pkgs.writeText "news-unread.txt" (concatMapStringsSep "\n\n"
concatMapStringsSep "\n\n" (entry: (entry:
let let
time = replaceStrings ["T"] [" "] (removeSuffix "+00:00" entry.time); time =
in replaceStrings [ "T" ] [ " " ] (removeSuffix "+00:00" entry.time);
'' in ''
* ${time} * ${time}
${replaceStrings ["\n"] ["\n "] entry.message} ${replaceStrings [ "\n" ] [ "\n " ] entry.message}
'' '') newsFiltered);
) newsFiltered
);
newsFileAll = pkgs.writeText "news-all.txt" ( newsFileAll = pkgs.writeText "news-all.txt" (concatMapStringsSep "\n\n"
concatMapStringsSep "\n\n" (entry: (entry:
let let
flag = if newsIsRead entry then "read" else "unread"; flag = if newsIsRead entry then "read" else "unread";
time = replaceStrings ["T"] [" "] (removeSuffix "+00:00" entry.time); time =
in replaceStrings [ "T" ] [ " " ] (removeSuffix "+00:00" entry.time);
'' in ''
* ${time} [${flag}] * ${time} [${flag}]
${replaceStrings ["\n"] ["\n "] entry.message} ${replaceStrings [ "\n" ] [ "\n " ] entry.message}
'' '') env.newsEntries);
) env.newsEntries
);
# File where each line corresponds to an unread news entry # File where each line corresponds to an unread news entry
# identifier. If non-empty then the file ends in "\n". # identifier. If non-empty then the file ends in "\n".
newsUnreadIdsFile = pkgs.writeText "news-unread-ids" ( newsUnreadIdsFile = pkgs.writeText "news-unread-ids"
let (let text = concatMapStringsSep "\n" (entry: entry.id) newsFiltered;
text = concatMapStringsSep "\n" (entry: entry.id) newsFiltered; in text + optionalString (text != "") "\n");
in
text + optionalString (text != "") "\n"
);
newsInfo = pkgs.writeText "news-info.sh" '' newsInfo = pkgs.writeText "news-info.sh" ''
local newsNumUnread=${toString newsNumUnread} local newsNumUnread=${toString newsNumUnread}
@ -82,8 +68,7 @@ let
local newsUnreadIdsFile="${newsUnreadIdsFile}" local newsUnreadIdsFile="${newsUnreadIdsFile}"
''; '';
in in {
{
inherit (env) activationPackage; inherit (env) activationPackage;
inherit newsInfo; inherit newsInfo;
} }

View file

@ -364,7 +364,10 @@ with lib;
StartCalendarInterval = mkOption { StartCalendarInterval = mkOption {
default = null; default = null;
example = { Hour = 2; Minute = 30; }; example = {
Hour = 2;
Minute = 30;
};
description = '' description = ''
This optional key causes the job to be started every calendar interval as specified. Missing arguments This optional key causes the job to be started every calendar interval as specified. Missing arguments
are considered to be wildcard. The semantics are much like <literal>crontab(5)</literal>. Unlike cron which skips job are considered to be wildcard. The semantics are much like <literal>crontab(5)</literal>. Unlike cron which skips job
@ -652,7 +655,8 @@ with lib;
}; };
ProcessType = mkOption { ProcessType = mkOption {
type = types.nullOr (types.enum [ "Background" "Standard" "Adaptive" "Interactive" ]); type = types.nullOr
(types.enum [ "Background" "Standard" "Adaptive" "Interactive" ]);
default = null; default = null;
example = "Background"; example = "Background";
description = '' description = ''
@ -840,7 +844,8 @@ with lib;
}; };
Bonjour = mkOption { Bonjour = mkOption {
type = types.nullOr (types.either types.bool (types.listOf types.str)); type =
types.nullOr (types.either types.bool (types.listOf types.str));
default = null; default = null;
description = '' description = ''
This optional key can be used to request that the service be registered with the This optional key can be used to request that the service be registered with the
@ -864,6 +869,5 @@ with lib;
}; };
}; };
config = { config = { };
};
} }

View file

@ -8,9 +8,7 @@ let
docs = import ../docs { inherit lib pkgs; }; docs = import ../docs { inherit lib pkgs; };
in in {
{
options = { options = {
manual.html.enable = mkOption { manual.html.enable = mkOption {
type = types.bool; type = types.bool;