Last active
August 29, 2015 14:16
-
-
Save joachifm/703ef3c6ff15b6fcb41b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs>{} | |
, lib ? pkgs.lib | |
, configuration ? import ./configuration.nix | |
, nixos ? import <nixpkgs/nixos>{ inherit configuration; } | |
}: | |
let | |
inherit (lib) filterAttrs mapAttrs; | |
inherit (builtins) hasAttr getAttr; | |
uids = nixos.config.ids.uids; | |
gids = nixos.config.ids.gids; | |
in | |
rec { | |
## map users to conflicting entries in groups: { userName = { conflictingGroup = gid } } | |
conflicting-ids = | |
filterAttrs (k: v: v != {}) ( | |
mapAttrs (userName: userId: | |
filterAttrs (groupName: groupId: userId == groupId && (groupName != userName)) | |
gids) | |
uids); | |
## find mismatched user/group: { userName = mismatchedGid } | |
mismatched-uid-and-gid = | |
filterAttrs (k: v: hasAttr k gids && getAttr k gids != v) uids; | |
## find groups with no corresponding uid: { groupName = gid } | |
## | |
## these uids are RESERVED (i.e., may only be used by the user which corresponds to the group). | |
gid-with-no-uid = | |
filterAttrs (k: v: !hasAttr k uids) gids; | |
reserved-uids = gid-with-no-uid; | |
## find users with no corresponding gid: { userName = uid } | |
## | |
## these gids are RESERVED (i.e., may only be used by the group which corresponds to the user). | |
uid-with-no-gid = | |
filterAttrs (k: v: !hasAttr k gids) uids; | |
reserved-gids = uid-with-no-gid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment