global stylix and proper oh-my-posh

feature/nixinite
Ingolf Wagner 2023-07-01 00:20:03 +02:00
parent 28ec876251
commit 93560cdd74
Signed by: palo
GPG Key ID: 76BF5F1928B9618B
21 changed files with 240 additions and 86 deletions

View File

@ -33,4 +33,3 @@ My overlay is in here.
### assets
assets, like scripts which I dont want to write in nix-lang.

View File

@ -221,15 +221,16 @@
homeManagerModules = { config, ... }: {
imports = [
home-manager.nixosModules.home-manager
# stylix.nixosModules.stylix
stylix.nixosModules.stylix
];
stylix.image = ./nixos/assets/wallpaper.png;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.root = {
home.stateVersion = "22.11";
imports = [
home-manager-utils.hmModule
#stylix.homeManagerModules.stylix
];
};
home-manager.users.mainUser = {
@ -237,7 +238,6 @@
imports = [
doom-emacs-nix.hmModule
home-manager-utils.hmModule
stylix.homeManagerModules.stylix
];
};
};
@ -295,7 +295,7 @@
modules = [
#retiolum.nixosModules.retiolum
#private_assets.nixosModules.jobrad
#homeManagerModules
homeManagerModules
];
};

View File

@ -1,19 +1,18 @@
# remote installation iso
* `./config.nix` : to generate the installation image
* `./remote-service.nix` : tor configuration you have to start on your machine.
- `./config.nix` : to generate the installation image
- `./remote-service.nix` : tor configuration you have to start on your machine.
## Steps
* import `./remote-service.nix` in your `/etc/nixos/configuration.nix`
* `nixos-rebuild switch`
* run `remote-install-get-hiddenReceiver` and enter the result in `./config.nix` as `hiddenReceiver`
* set the public key in `./config.nix`
* run `nixos-generate -f install-iso -c ./config.nix`
* prepare the usb stick : `sudo if=<path of the iso> of=/dev/<device> bs=4096`
* boot the usb-stick at the new machine
* run `remote-install-start-service`
* after some time you will see a you can use to login to the new machine.
- import `./remote-service.nix` in your `/etc/nixos/configuration.nix`
- `nixos-rebuild switch`
- run `remote-install-get-hiddenReceiver` and enter the result in `./config.nix` as `hiddenReceiver`
- set the public key in `./config.nix`
- run `nixos-generate -f install-iso -c ./config.nix`
- prepare the usb stick : `sudo if=<path of the iso> of=/dev/<device> bs=4096`
- boot the usb-stick at the new machine
- run `remote-install-start-service`
- after some time you will see a you can use to login to the new machine.
Now you can do the normal installations procedure.

View File

@ -32,4 +32,3 @@ nix-shell -I nixpkgs=channel:nixos-unstable -p nixos-generators
iptables -F # kill firewall
python -m http.server 80 # nix-shell -p python3Full
```

View File

@ -2,12 +2,12 @@
## reset password
* use `sfdisk -l` to list partitions
* find the partition which holds `Windows/System32/config`
* mount it `mkdir -p /media/sda2; mount /dev/sda2 /media/sda2`
* `cd /media/sda2/Windows/System32/config`
* list SAM database `chntpw -l SAM`
* edit SAM database `chntpw -i SAM`
* reboot
- use `sfdisk -l` to list partitions
- find the partition which holds `Windows/System32/config`
- mount it `mkdir -p /media/sda2; mount /dev/sda2 /media/sda2`
- `cd /media/sda2/Windows/System32/config`
- list SAM database `chntpw -l SAM`
- edit SAM database `chntpw -i SAM`
- reboot
more details [here](https://opensource.com/article/18/3/how-reset-windows-password-linux).

View File

@ -29,6 +29,8 @@ in
enable = true;
bars = {
my = {
icons = "awesome5";
theme = "gruvbox-light";
# https://github.com/greshake/i3status-rust/blob/v0.22.0/doc/blocks.md
blocks = [
{

View File

@ -8,33 +8,21 @@ with lib;
config = mkIf (config.components.gui.style.enable) {
home-manager.users.mainUser = {
stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-light-medium.yaml";
stylix.image = ../../assets/wallpaper.png;
stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-light-medium.yaml";
programs.i3status-rust.bars.my = {
icons = "awesome5";
theme = "gruvbox-light";
stylix.fonts = {
serif = config.stylix.fonts.monospace;
sansSerif = config.stylix.fonts.monospace;
monospace = {
package = pkgs.jetbrains-mono;
name = "JetBrains Mono";
};
stylix.fonts = {
serif = config.home-manager.users.mainUser.stylix.fonts.monospace;
sansSerif = config.home-manager.users.mainUser.stylix.fonts.monospace;
monospace = {
package = pkgs.jetbrains-mono;
name = "JetBrains Mono";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
};
fonts.fonts = with pkgs; [
corefonts

View File

@ -12,7 +12,7 @@ with lib;
./direnv.nix
./git.nix
./hoard.nix
./oh-my-posh.nix
./oh-my-posh
./remote-install.nix
./wtf.nix
./zsh.nix

View File

@ -13,7 +13,8 @@ with lib;
poshConfig = {
programs.oh-my-posh = {
enable = true;
useTheme = "gruvbox";
# useTheme = "gruvbox";
settings = builtins.fromJSON (builtins.readFile ./gruvbox.json);
};
};
in

View File

@ -0,0 +1,65 @@
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#3A3A3A",
"foreground": "#ffffff",
"style": "powerline",
"template": "{{ if .WSL }}WSL at{{ end }} {{.Icon}} ",
"type": "os"
},
{
"background": "#fbf1c7",
"background_templates": ["{{ if .Root }}#af3a03{{ end }}"],
"foreground": "#282828",
"foreground_templates": ["{{ if .Root }}#fbf1c7{{ end }}"],
"powerline_symbol": "\ue0b0",
"style": "powerline",
"template": " {{ if .SSHSession }} {{ end }}{{ .HostName }} ",
"type": "session"
},
{
"background": "#458588",
"foreground": "#282828",
"powerline_symbol": "\ue0b0",
"properties": {
"style": "full"
},
"style": "powerline",
"template": " {{ .Path }} ",
"type": "path"
},
{
"background": "#98971A",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}",
"{{ if gt .Ahead 0 }}#B388FF{{ end }}",
"{{ if gt .Behind 0 }}#B388FF{{ end }}"
],
"foreground": "#282828",
"leading_diamond": "\ue0b6",
"powerline_symbol": "\ue0b0",
"properties": {
"branch_max_length": 25,
"fetch_stash_count": true,
"fetch_status": true,
"branch_icon": "\uE0A0 ",
"branch_identical_icon": "\u25CF"
},
"style": "powerline",
"template": " {{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
"trailing_diamond": "\ue0b4",
"type": "git"
}
],
"type": "prompt"
}
],
"console_title_template": "{{ .Folder }}",
"final_space": true,
"version": 2
}

View File

@ -2,6 +2,8 @@
imports = [
../../components
./hardware-configuration.nix
../../system/server
./disko-config.nix
@ -48,6 +50,10 @@
];
components.terminal.enable = true;
components.mainUser.enable = true;
components.gui.enable = false;
components.network.enable = true;
components.network.wifi.enable = false;

View File

@ -170,7 +170,9 @@ in
options.programs.custom.browser = {
enable = mkEnableOption "enable browsers";
# todo : it's not a list
configList = mkOption {
default = { };
type = with types;
attrsOf (submodule ({ name, ... }: {
options = {

View File

@ -1,6 +1,5 @@
# how to build and test
```
nix-build -E 'with import <nixpkgs> { overlays = [ (import "${<nix-writers>}/pkgs" )];} ; callPackage ./default.nix {}';
nix-build -E 'with import <nixpkgs> { overlays = [ (import "${<nix-writers>}/pkgs" )];} ; callPackage ./default.nix {}';
```

View File

@ -3225,4 +3225,4 @@
}
],
"macros": []
}
}

87
scripts/json2nix.py Normal file
View File

@ -0,0 +1,87 @@
"""
Converts JSON objects into nix (hackishly).
https://gist.github.com/Scoder12/0538252ed4b82d65e59115075369d34d
"""
import sys
import json
INDENT = " " * 2
def strip_comments(t):
# fixme: doesn't work if JSON strings contain //
return "\n".join(l.partition("//")[0] for l in t.split("\n"))
def indent(s):
return "\n".join(INDENT + i for i in s.split("\n"))
def nix_stringify(s):
# fixme: this doesn't handle string interpolation and possibly has more bugs
return json.dumps(s)
def sanitize_key(s):
if s and s.isalnum() and not s[0].isdigit():
return s
return nix_stringify(s)
def flatten_obj_item(k, v):
keys = [k]
val = v
while isinstance(val, dict) and len(val) == 1:
k = next(iter(val.keys()))
keys.append(k)
val = val[k]
return keys, val
def fmt_object(obj, flatten):
fields = []
for k, v in obj.items():
if flatten:
keys, val = flatten_obj_item(k, v)
formatted_key = ".".join(sanitize_key(i) for i in keys)
else:
formatted_key = sanitize_key(k)
val = v
fields.append(f"{formatted_key} = {fmt_any(val, flatten)};")
return "{\n" + indent("\n".join(fields)) + "\n}"
def fmt_array(o, flatten):
body = indent("\n".join(fmt_any(i, flatten) for i in o))
return f"[\n{body}\n]"
def fmt_any(o, flatten):
if isinstance(o, str) or isinstance(o, bool) or isinstance(o, int):
return json.dumps(o)
if isinstance(o, list):
return fmt_array(o, flatten)
if isinstance(o, dict):
return fmt_object(o, flatten)
raise TypeError(f"Unknown type {type(o)!r}")
def main():
flatten = "--flatten" in sys.argv
args = [a for a in sys.argv[1:] if not a.startswith("--")]
if len(args) < 1:
print(f"Usage: {sys.argv[0]} [--flatten] <file.json>", file=sys.stderr)
sys.exit(1)
with open(args[0], "r") as f:
data = json.loads(strip_comments(f.read()))
print(fmt_any(data, flatten=flatten))
if __name__ == "__main__":
main()

View File

@ -2,6 +2,6 @@
This example shows how you could use terranix as flake.
* `nix run` run `nix run ".#apply"`
* `nix run ".#apply"` run `terraform apply`
* `nix run ".#destroy"` run `terraform destroy`
- `nix run` run `nix run ".#apply"`
- `nix run ".#apply"` run `terraform apply`
- `nix run ".#destroy"` run `terraform destroy`

View File

@ -671,4 +671,4 @@
]
}
]
}
}

View File

@ -2,9 +2,9 @@
This setup shows:
* how to use a terranix module
* how to use 3rd party provision software after terraform.
* how to run terranix and terraform
- how to use a terranix module
- how to use 3rd party provision software after terraform.
- how to run terranix and terraform
Setup containing opinionated modules to deploy
[NixOS servers](https://nixos.org/)
@ -15,7 +15,7 @@ using
with my
[plops](https://github.com/mrVanDalo/plops)
provisioning tool for NixOS,
which is an overlay on
which is an overlay on
[krops](https://cgit.krebsco.de/krops/about/).
After server creation,
@ -34,22 +34,21 @@ here (e.g. NixOps, Ansible, ... )
## What you need
* a setup [passwordstore](https://www.passwordstore.org/).
* a [hcloud token](https://docs.hetzner.cloud/#overview-getting-started)
- a setup [passwordstore](https://www.passwordstore.org/).
- a [hcloud token](https://docs.hetzner.cloud/#overview-getting-started)
stored under `development/hetzner.com/api-token`
## Steps
* `terraform-prepare`: to create ssh keys.
* `terraform-build`: to run terranix and terraform do create server.
* `terraform-destroy`: to delete server (don't forget that step, or else it gets costly)
* `terraform-cleanup`: to delete ssh keys and terraform data.
- `terraform-prepare`: to create ssh keys.
- `terraform-build`: to run terranix and terraform do create server.
- `terraform-destroy`: to delete server (don't forget that step, or else it gets costly)
- `terraform-cleanup`: to delete ssh keys and terraform data.
## DNS
define domains with your nameserver and update `jitsi.nix` and `workadventure.nix`.
* `meet.${domain}` to given ip4 address
* `party.${domain}` to given ip4 address
* `*.party.${domain}` to given ip4 address
- `meet.${domain}` to given ip4 address
- `party.${domain}` to given ip4 address
- `*.party.${domain}` to given ip4 address

View File

@ -1,4 +1,3 @@
A setup to test tinc on a hetzner box
# steps

View File

@ -2,9 +2,9 @@
This setup shows:
* how to use a terranix module
* how to use 3rd party provision software after terraform.
* how to run terranix and terraform
- how to use a terranix module
- how to use 3rd party provision software after terraform.
- how to run terranix and terraform
Setup containing opinionated modules to deploy
[NixOS servers](https://nixos.org/)
@ -15,7 +15,7 @@ using
with my
[plops](https://github.com/mrVanDalo/plops)
provisioning tool for NixOS,
which is an overlay on
which is an overlay on
[krops](https://cgit.krebsco.de/krops/about/).
After server creation,
@ -34,22 +34,21 @@ here (e.g. NixOps, Ansible, ... )
## What you need
* a setup [passwordstore](https://www.passwordstore.org/).
* a [hcloud token](https://docs.hetzner.cloud/#overview-getting-started)
- a setup [passwordstore](https://www.passwordstore.org/).
- a [hcloud token](https://docs.hetzner.cloud/#overview-getting-started)
stored under `development/hetzner.com/api-token`
## Steps
* `terraform-prepare`: to create ssh keys.
* `terraform-build`: to run terranix and terraform do create server.
* `terraform-destroy`: to delete server (don't forget that step, or else it gets costly)
* `terraform-cleanup`: to delete ssh keys and terraform data.
- `terraform-prepare`: to create ssh keys.
- `terraform-build`: to run terranix and terraform do create server.
- `terraform-destroy`: to delete server (don't forget that step, or else it gets costly)
- `terraform-cleanup`: to delete ssh keys and terraform data.
## DNS
define domains with your nameserver and update `jitsi.nix` and `workadventure.nix`.
* `meet.${domain}` to given ip4 address
* `party.${domain}` to given ip4 address
* `*.party.${domain}` to given ip4 address
- `meet.${domain}` to given ip4 address
- `party.${domain}` to given ip4 address
- `*.party.${domain}` to given ip4 address

View File

@ -22,4 +22,14 @@ excludes = ["./scripts/hetzner-dedicated-wipe-and-install-nixos.sh"]
[formatter.python]
command = "black"
includes = ["*.py"]
includes = ["*.py"]
[formatter.media]
command = "prettier"
options = ["--write"]
includes = [
"*.json",
"*.md",
"*.yaml",
"*.yml",
]