Skip to content

Instantly share code, notes, and snippets.

@disassembler
Created May 30, 2017 19:11
Show Gist options
  • Save disassembler/6f6eb26dec02aa765a9ed8f0d52c0a43 to your computer and use it in GitHub Desktop.
Save disassembler/6f6eb26dec02aa765a9ed8f0d52c0a43 to your computer and use it in GitHub Desktop.
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ lib, config, pkgs, fetchgit, ... }:
let
parameters = import ./parameters.nix;
profiles = (import ./modules);
baseServices = {
locate.enable = true;
openssh.enable = true;
openssh.permitRootLogin = "without-password";
};
basePackages = with pkgs; [
git
neovim
tmux
screen
nix-repl # repl for the nix language
wget
openssh
openssl
fasd
bind
];
in {
imports =
[ # Include the results of the hardware scan.
(./hardware-configurations + "/${parameters.machine}.nix")
# Machine specific config
(
import (./machines + "/${parameters.machine}.nix") {
inherit lib;
inherit config;
inherit pkgs;
inherit baseServices;
inherit basePackages;
inherit parameters;
}
)
]
// profiles.profiles;
#config.profiles.zsh.enable = true;
# Select internationalisation properties.
i18n = {
consoleFont = "Lat2-Terminus16";
consoleKeyMap = "us";
defaultLocale = "en_US.UTF-8";
};
# Set your time zone.
time.timeZone = "America/New_York";
# List services that you want to enable:
programs = {
ssh.forwardX11 = false;
ssh.startAgent = true;
};
# Define a user account. Don't forget to set a password with ‘passwd’.
users.extraUsers.root.shell = pkgs.bash;
users.extraUsers.sam = {
isNormalUser = true;
description = "Sam Leathers";
uid = 1000;
extraGroups = [ "wheel" "docker" "disk" "video" "vboxusers"];
shell = pkgs.zsh;
openssh.authorizedKeys.keys = parameters.sam_ssh_keys;
};
}
let
pkgs = import <nixpkgs> {};
profiles = import ./modules/module-list.nix;
options = (import <nixpkgs/nixos/lib/eval-config.nix> {
modules = profiles;
}).options;
optionsList = with pkgs.lib;
filter (opt: opt.visible && !opt.internal) (optionAttrSetToDocList options);
# Replace functions by the string <function>
substFunction = with pkgs.lib; x:
if builtins.isAttrs x then mapAttrs (name: substFunction) x
else if builtins.isList x then map substFunction x
else if builtins.isFunction x then "<function>"
else x;
optionsList' = with pkgs.lib; flip map optionsList (opt: opt // {
declarations = opt.declarations;
}
// optionalAttrs (opt ? description) { example = substFunction opt.description; }
// optionalAttrs (opt ? example) { example = substFunction opt.example; }
// optionalAttrs (opt ? default) { default = substFunction opt.default; }
// optionalAttrs (opt ? type) { type = substFunction opt.type; });
prefixes = ["profiles" "attributes" "roles"];
in with pkgs.lib; {
inherit profiles;
options = pkgs.stdenv.mkDerivation {
name = "options-json";
buildCommand = ''
mkdir -p $out
cp ${pkgs.writeText "options.json" (concatMapStringsSep "\n" (v: ''
* `${v.name}`:
${v.value.description or "No description"}
**Default:** ${builtins.toJSON v.value.default or "..."}
**Example:** ${if v.value.description == v.value.example then "..." else (builtins.toJSON v.value.example)}
'')
(filter (v: any (p: hasPrefix p v.name) prefixes)
(map (o: {
name = o.name;
value = removeAttrs o ["name" "visible" "internal"];
}) optionsList'
)
)
)} $out/options.md
''; # */
meta.description = "List of NixOS options in JSON format";
};
}
[
./profiles/zsh.nix
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment