diff --git a/README.md b/README.md index f8cce04..a559b32 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,36 @@ -# My NixOS configuration +My NixOS configuration +---------------------- -My machines and dotfiles management using Nix / NixOS. +My configurations for NixOS using flakes. For now only my desktop computer is +configured with this system. -## Installation - -Project contains a devshell installing all needed and a -[Taskfile](https://Taskfile.dev) is available to help manage elements whether -Home-Manager or NixOS configuration. +## Install ``` -task --list-all -task: Available tasks for this project: -* check:flake: Check flake -* check:sh: Check SH files, will call all check:sh:* tasks -* check:sh:shellcheck: Pass Shellcheck on all *.sh files -* check:sh:shfmt: Pass shfmt in check mode on all sh files -* check:typos: Check typos in all files -* home:*:*: Manage Home-Manager configuration, use home:verb:target format -* home:gc: Garbage collect Home-Manager packages -* home:list-gen: List Home-Manager generations -* host:*:switch: Switch both Home-Manager and NixOS generations -* host:*:update: Update package version then build NixOS and Home-Manager -* nixos:*:*: Manage NixOS build, use nixos:verb:target format -* nixos:gc: Garbage collect NixOS -* nixos:list-gen: List Nixos generations +doas nixos-rebuild switch --flake ".#mrmeeseeks" ``` -Managing *NixOS* installation, you can use all `nixos:*` targets for example: +## Update the flakes.lock + +``` +nix flake update +doas nixos-rebuild switch --flake ".#mrmeeseeks" +``` + +## Update manual packages from github + +Some modules use `fetchFromGithub` who need *SHA-256* hash to meet +reproductibility. Theses hashed can be obtain with `nix-prefetch-github`: ```shell -# build mrmeeseeks nixos: -task nixos:build:mrmeeseeks - -# build/switch nixos installation for mrmeeseeks -task nixos:switch:mrmeeseeks - -# build ephase home configuration for mrmeeseeks: -task home:build:mrmeeseeks - -# build / switch ephase home configuration for mrmeeseeks +$ nix-shell -p nix-prefetch-github +$ nix-prefetch-ghithub --rev v1.22.0 sindresorhus pure +{ + "owner": "sindresorhus", + "repo": "pure", + "rev": "87e6f5dd4c793f6d980532205aaefe196780606f", + "sha256": "TR4CyBZ+KoZRs9XDmWE5lJuUXXU1J8E2Z63nt+FS+5w=" +} ``` -## Update nixpkgs version - -Update packages repositories version can be done with `host::update`: - -``` -task host:mrmeeseeks:update -``` - -`flake.lock` file will be updated then both NixOS and Home-Manager will be -rebuilt. Note than new generation will not be activated, to do so you need to: - -``` -task host:mrmeeseeks:switch -``` +In this example we have obtained the hash for the specific 1.22.0 version. diff --git a/Taskfile.dist.yaml b/Taskfile.dist.yaml deleted file mode 100644 index 6980847..0000000 --- a/Taskfile.dist.yaml +++ /dev/null @@ -1,140 +0,0 @@ ---- -version: "3" -set: [errexit, pipefail, nounset] -shopt: [globstar] -env: - GENERATION_IN_DAYS: 20d - -tasks: - check:sh: - desc: Check SH files, will call all check:sh:* tasks - cmds: - - task: check:sh:shellcheck - - task: check:sh:shfmt - check:sh:shellcheck: - desc: Pass Shellcheck on all *.sh files - cmds: - - find . -type f -name "*.sh" -exec shellcheck {} \; - sources: - - "**/*.sh" - check:sh:shfmt: - desc: Pass shfmt in check mode on all sh files - cmds: - - find . -type f -name "*.sh" -exec shfmt -d -ln bash -i 4 {} \; - sources: - - "**/*.sh" - check:typos: - desc: Check typos in all files - cmds: - - typos . - check:flake: - desc: Check flake - cmds: - - nix flake check - sources: - - "**/*.nix" - - host:*:update: - desc: Update package version then build NixOS and Home-Manager - vars: - TARGET: "{{index .MATCH 0}}" - cmds: - - nix flake update - - task: nixos:build:{{.TARGET}} - - task: home:build:{{.TARGET}} - preconditions: - - sh: '[[ -d ./hosts/{{.TARGET}} ]]' - msg: host `{{.TARGET}}` not found in `hosts/` directory - - host:*:switch: - desc: Switch both Home-Manager and NixOS generations - vars: - TARGET: "{{index .MATCH 0}}" - cmds: - - task: nixos:switch:{{.TARGET}} - - task: home:switch:{{.TARGET}} - preconditions: - - sh: '[[ -d ./hosts/{{.TARGET}} ]]' - msg: host `{{.TARGET}}` not found in `hosts/` directory - - nixos:*:*: - desc: Manage NixOS build, use nixos:verb:target format - vars: - VERB: "{{index .MATCH 0}}" - TARGET: "{{index .MATCH 1}}" - preconditions: - - sh: '[[ {{.VERB}} = build || {{.VERB}} = test || {{.VERB}} = switch ]]' - msg: verb must be build, test or switch - cmds: - - task: nixos:{{.VERB}} - vars: - TARGET: "{{.TARGET}}" - - nixos:build: - internal: true - cmds: - - nixos-rebuild --flake .#{{.TARGET}} build - requires: - vars: [TARGET] - - nixos:switch: - internal: true - cmds: - - doas nixos-rebuild --flake .#{{.TARGET}} switch - requires: - vars: [TARGET] - - nixos:test: - internal: true - cmds: - - doas nixos-rebuild --flake .#{{.TARGET}} test - requires: - vars: [TARGET] - - nixos:list-gen: - desc: List Nixos generations - cmds: - - nixos-rebuild list-generations - - nixos:gc: - desc: Garbage collect NixOS - cmds: - - doas nix-collect-garbage --delete-older-than {{.GENERATION_IN_DAYS}} - - home:*:*: - desc: Manage Home-Manager configuration, use home:verb:target format - vars: - VERB: "{{index .MATCH 0}}" - TARGET: "{{index .MATCH 1}}" - preconditions: - - sh: '[[ {{.VERB}} = build || {{.VERB}} = switch ]]' - msg: verb must be build or switch - cmds: - - task: home:{{.VERB}} - vars: - TARGET: "{{.TARGET}}" - - home:build: - internal: true - cmds: - - home-manager build --flake .#{{.TARGET}} - requires: - vars: [TARGET] - - home:switch: - internal: true - cmds: - - home-manager switch --flake .#{{.TARGET}} - requires: - vars: [TARGET] - - home:list-gen: - desc: List Home-Manager generations - cmds: - - home-manager generations - - home:gc: - desc: Garbage collect Home-Manager packages - cmds: - - home-manager expire-generations {{.GENERATION_IN_DAYS}} - - nix store gc diff --git a/_typos.toml b/_typos.toml index 42bfc5c..a44fcd3 100644 --- a/_typos.toml +++ b/_typos.toml @@ -9,7 +9,3 @@ edn = "edn" [type.images] extend-glob = ["*.png"] check-file = false - -[type.lua] -extend-glob = ["*.lua"] -check-file = false diff --git a/flake.nix b/flake.nix index 84149e0..8d89bce 100644 --- a/flake.nix +++ b/flake.nix @@ -17,46 +17,18 @@ }; }; outputs = { self, nixpkgs, home-manager, nur, nixgl, sops-nix, ... }@inputs: - let - stateVersion = "23.11"; - - allSystems = [ - "x86_64-linux" # 64bit AMD/Intel x86 - "aarch64-linux" # 64bit ARM Linux - ]; +let + stateVersion = "23.11"; - forAllSystems = fn: - nixpkgs.lib.genAttrs allSystems - (system: fn { pkgs = import nixpkgs { inherit system; }; }); - - createNixosSystem = { system, hostname, username ? "ephase" }: nixpkgs.lib.nixosSystem { - system = system; - specialArgs = { - inherit stateVersion inputs; - hostname = hostname; - username = username; - }; - modules = [ - ./nixos/default.nix - ]; - }; - - createHomeConfiguration = { system ? "x86_64-linux", hostname, username ? "ephase" }: - home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { - system = system; - overlays = [ nixgl.overlay ]; - }; - extraSpecialArgs = { - inherit stateVersion inputs; - hostname = hostname; - username = username; - }; - modules = [ - ./home-manager/default.nix - ]; - }; - in { + allSystems = [ + "x86_64-linux" # 64bit AMD/Intel x86 + "aarch64-linux" # 64bit ARM Linux + ]; + + forAllSystems = fn: + nixpkgs.lib.genAttrs allSystems + (system: fn { pkgs = import nixpkgs { inherit system; }; }); +in { devShells = forAllSystems ({ pkgs }: { default = pkgs.mkShell { name = "nixfiles"; @@ -74,19 +46,71 @@ }; }); nixosConfigurations = { - morty = createNixosSystem { system = "x86_64-linux"; hostname = "morty"; }; - mrmeeseeks = createNixosSystem { system = "x86_64-linux"; hostname = "mrmeeseeks";}; - luci = createNixosSystem { system = "x86_64-linux"; hostname = "luci"; }; + morty = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inherit stateVersion inputs; + hostname = "morty"; + username = "ephase"; + }; + modules = [ + ./nixos/default.nix + home-manager.nixosModule + ]; + }; + mrmeeseeks = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inherit stateVersion inputs; + hostname = "mrmeeseeks"; + username = "ephase"; + }; + modules = [ + ./nixos/default.nix + home-manager.nixosModule + ]; + }; + luci = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inherit stateVersion inputs; + hostname = "luci"; + username = "ephase"; + }; + modules = [ + ./nixos/default.nix + home-manager.nixosModule + ]; + }; }; homeConfigurations = { - "rick" = createHomeConfiguration { system = "aarch64-linux"; hostname = "rick";}; - "luci" = createHomeConfiguration { system = "x86_64-linux"; hostname = "luci";}; - "morty" = createHomeConfiguration { system = "x86_64-linux"; hostname = "morty";}; - "mrmeeseeks" = createHomeConfiguration { system = "x86_64-linux"; hostname = "mrmeeseeks";}; - "work" = createHomeConfiguration { - system = "x86_64-linux"; - hostname = "work"; - username = "yorick-barbanneau"; + rick = home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { + system = "aarch64-linux"; + overlays = [ nixgl.overlay ]; + }; + extraSpecialArgs = { + inherit stateVersion inputs; + hostname = "rick"; + username = "ephase"; + }; + modules = [ + ./home-manager/default.nix + ]; + }; + work = home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ nixgl.overlay ]; + }; + extraSpecialArgs = { + inherit stateVersion inputs; + hostname = "work"; + username = "yorick-barbanneau"; + }; + modules = [ + ./home-manager/default.nix + ]; }; }; }; diff --git a/home-manager/base.nix b/home-manager/base.nix index 2501587..13a4a20 100644 --- a/home-manager/base.nix +++ b/home-manager/base.nix @@ -1,4 +1,13 @@ -_: +{ lib, hostname, ...}: { - + programs.home-manager.enable = true; + home.sessionPath = [ + "$HOME/.local/bin" + ]; + imports = [ + ../hosts/${hostname}/home-config.nix + ../modules/home-manager/default.nix + ] ++ lib.optional ( + builtins.pathExists ../hosts/${hostname}/includes/home-manager.nix + ) ../hosts/${hostname}/includes/home-manager.nix; } diff --git a/home-manager/default.nix b/home-manager/default.nix index befa969..6470228 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -1,23 +1,12 @@ -{ inputs, lib, stateVersion, username, hostname, ... }: +{ stateVersion, username, inputs, ... }: { + home.stateVersion = stateVersion; + home.username = "${username}"; + home.homeDirectory = "/home/${username}"; + fonts.fontconfig.enable = true; imports = [ inputs.sops-nix.homeManagerModules.sops - ../hosts/${hostname}/home-config.nix + ./base.nix ../nixos/includes/system/overlay.nix - ../modules/home-manager/default.nix - ] ++ lib.optional ( - builtins.pathExists ../hosts/${hostname}/includes/home-manager.nix - ) ../hosts/${hostname}/includes/home-manager.nix; - - nixpkgs.config.allowUnfree = true; - programs.home-manager.enable = true; - fonts.fontconfig.enable = true; - - home = { - inherit stateVersion username; - homeDirectory = "/home/${username}"; - sessionPath = [ - "$HOME/.local/bin" - ]; - }; + ]; } diff --git a/lefthook.yaml b/lefthook.yaml index 4410eea..76a8dd0 100644 --- a/lefthook.yaml +++ b/lefthook.yaml @@ -8,19 +8,11 @@ commit-msg: run: cat {1} | convco check --from-stdin lint:typos: run: cat {1} | typos - - pre-commit: parallel: false commands: lint:typos:staged_files: run: typos {staged_files} - shellcheck: - glob: "*.sh" - run: shellcheck {staged_files} - shfmt: - glob: "*.sh" - run: shfmt -d -ln bash -i 4 {staged_files} - pre-push: parallel: false commands: diff --git a/modules/home-manager/video/kdenlive/default.nix b/modules/home-manager/video/kdenlive/default.nix index 3073e0b..267d79c 100644 --- a/modules/home-manager/video/kdenlive/default.nix +++ b/modules/home-manager/video/kdenlive/default.nix @@ -14,6 +14,6 @@ in frei0r inkscape ]; - home.file.".local/bin/create_conf".source = ./files/create_conf.sh; + home.file.".local/bin/create_conf".source = ./files/create_conf; }; } diff --git a/modules/home-manager/video/kdenlive/files/create_conf b/modules/home-manager/video/kdenlive/files/create_conf new file mode 100755 index 0000000..f0f929f --- /dev/null +++ b/modules/home-manager/video/kdenlive/files/create_conf @@ -0,0 +1,202 @@ +#!/usr/bin/env bash + +error() { + >&2 printf "\e[31mE\e[0m %s\n" "$1" +} + +die() { + error "$*" + exit 1 +} +# shellcheck disable=SC2317 +process_args() { + while :; do + case $1 in + -l|--label) + key_label="$2" + shift + ;; + -r|--recorder) + recorder_label="$2" + shift + ;; + *) + break + esac + shift + done +} + +mount_device() { + local label="$1" + local unmount="${2:-0}" + local device + if [[ $unmount -eq 1 ]]; then + printf "Unm" + else + printf "M" + fi + printf "ount device with Label %s\n" "$label" + device="/dev/$(lsblk -o KNAME,LABEL | grep "${label}" | awk '{print $1}')" + + # check is we found a device with this name + if [[ $device = "/dev/" ]]; then + error "Can't get device named $label is device plugged?" + return 1 + fi + local command + if [[ $unmount -eq 1 ]]; then + command="unmount" + else + command="mount" + fi + + if ! udisksctl "${command}" -b "${device}"; then + error " -> Error mounting device $device for $label" + return 1 + fi + sleep 1 + return 0 +} + +get_file_hash() { + local file + local file_size + + file=$1 + file_size=${2:-1} + if (( file_size != -1 )) + then + if [ -f "$file" ] + then + if (( file_size > 0 )) + then + if (( file_size > 2000000 )) + then + #calculate + local tmp_file + tmp_file=mktemp + head -c 1MB "$file" > "$tmp_file" + tail -c 1MB "$file" >> "$tmp_file" + printf "%s" "$(md5sum "$tmp_file" | cut -d" " -f 1)" + rm "$tmp_file" + else + printf "%s" "$(md5sum "$file" | cut -d" " -f 1)" + fi + return + fi + fi + fi + printf "%s" -1 +} + +move_file(){ + local source="$1" + local destination="$2" + + printf "Move %s to %s:\n" "$source" "$destination" + if [[ ! -d "${destination%/*}" ]]; then + error "$destination directory does not exists" + return 1 + fi + + if ! mv "$source" "$destination"; then + error "Error moving $source file, file must not exists" + return 1 + fi + return 0 +} + +get_file_size() { + local file + file=$1 + if [ -f "$file" ] + then + wc -c < "$file" + return + fi + printf "%s" -1 +} + +insert_media() { + local filename filesize filehash tag + filename="$1" + tag="$2" + [ ! -f "$filename" ] && { + error "File $filename not found, can't insert media"; + return; + } + [ -z "$tag" ] && { + error "Tag not defined, can't insert media" + } + filesize=$(get_file_size "$filename") + filehash=$(get_file_hash "$filename" "$filesize") + sed -i -e "s#\[\[${tag}\]\]#${filename}#g" \ + -e "s#\[\[${tag}_filesize\]\]#${filesize}#g" \ + -e "s#\[\[${tag}_filehash\]\]#${filehash}#g" \ + "${folder}/montage.kdenlive" || { + error "sed command error on insert media!" + } +} + +base_dir="${HOME}/medias/videos/sambab" + +conf="$*" +key_label=${key_label:-SAMBAB} +recorder_label=${recorder_label:-"LS-100"} + +printf "Creation de la conférence de %s\n" "$conf" +cd ~/medias/videos/sambab || exit 1 + +#Get las friday date for creating folder +friday=$(date --date='last Friday' +"%Y.%m.%d") + +#Add basedir, then I have my directory +folder="${base_dir}/${friday}-${conf// /_}" + +# create it +mkdir "${folder}/"{rushes,audio,titles} -p || die "folder creation failed" + + +cp "${base_dir}/logo_amis.svg" "${folder}/titles" || die "SVG copy failed!" +cp "${base_dir}/template.kdenlive" "${folder}/montage.kdenlive" || die "Template copy failed!" + +inkscape_date=$(LC_ALL=fr_FR.UTF-8 date --date='last Friday' +"%A %d %B %Y") + +printf "Put Name on title\n" +sed -i "s/\[\[conf\]\]/${conf//_/ }/g" "${folder}/titles/logo_amis.svg" || die "Change text on credits screen failed!" + +printf "Put date on title\n" +sed -i "s/\[\[date\]\]/${inkscape_date}/g" "${folder}/titles/logo_amis.svg" || die "Change date failed!" + +printf "Export SVG title \n" +inkscape --export-type="png" "${folder}/titles/logo_amis.svg" || die "Export failed" + +printf "Importing PNG File in %s/montage.kdenlive \n" "$folder" +insert_media "$folder/titles/logo_amis.png" "logo" + +## Get file from USB key +if mount_device "$key_label"; then + if move_file "/run/media/${USER}/${key_label}/RECORD/EXREC/"*.MP3 "${folder}/audio/audio.mp3"; then + insert_media "${folder}/audio/audio.mp3" + fi + + if move_file "/run/media/${USER}/${key_label}/$(date --date='last Friday' +'%Y-%m-%d')"\ *.mkv "${folder}/rushes/obs.mkv"; + then + insert_media "${folder}/rushes/obs.mkv" video + fi + mount_device "$key_label" 1 +fi + +## Get audio file from RECORDER +if mount_device "$recorder_label"; then + if move_file "/run/media/${USER}/${recorder_label}/RECORDER/FOLDER_A/"VOC_*.wav "${folder}/audio/recorder.wav"; then + insert_media "${folder}/audio/recorder.wav" + fi + mount_device "${recorder_label}" 1 +fi + +printf "Change root folder in montage.kdenlive to %s\n" "$folder" +# sed -i -e "s#\[\[root_folder\]\]#${folder}#g" "${folder}/montage.kdenlive" + +exit 0 diff --git a/modules/home-manager/video/kdenlive/files/create_conf.sh b/modules/home-manager/video/kdenlive/files/create_conf.sh deleted file mode 100755 index e58df6f..0000000 --- a/modules/home-manager/video/kdenlive/files/create_conf.sh +++ /dev/null @@ -1,235 +0,0 @@ -#!/usr/bin/env bash - -error() { - printf -v message "\e[31mERROR:\e[0m %s\n" "$1" - message="${message} \e[1mStack trace\e[0m:\n" - for ((i = 1; i < ${#FUNCNAME[@]}; i++)); do - if [[ $i = $((${#FUNCNAME[@]} - 1)) ]]; then - message="${message} └" - else - message="${message} ├" - fi - message="${message}─ source:\e[3;34m${BASH_SOURCE[$i]}\e[0m" - message="${message} function:\e[3;34m${FUNCNAME[$i]}\e[0m" - message="${message} line:\e[3;34m${BASH_LINENO[$i - 1]}\e[0m\n" - done - >&2 printf "%b\n" "${message}" -} - -die() { - error "$*" - exit 1 -} -# shellcheck disable=SC2317 -process_args() { - while :; do - case $1 in - -l | --label) - key_label="$2" - shift - ;; - -r | --recorder) - recorder_label="$2" - shift - ;; - *) - conf="$*" - break - ;; - esac - shift - done -} - -mount_device() { - if [[ $# -lt 1 || $# -gt 2 ]]; then - error "mount_device need 1 or 2 arguments, $# provided : '$*'" - return 1 - fi - local label="$1" - local unmount="${2:-0}" - local device - if [[ $unmount -eq 1 ]]; then - printf "Unm" - else - printf "M" - fi - printf "ount device with Label %s\n" "$label" - device="/dev/$(lsblk -o KNAME,LABEL | grep "${label}" | awk '{print $1}')" - - # check is we found a device with this name - if [[ $device = "/dev/" ]]; then - error "Can't get device named $label is device plugged?" - return 1 - fi - local command - if [[ $unmount -eq 1 ]]; then - command="unmount" - else - command="mount" - fi - - if ! udisksctl "${command}" -b "${device}"; then - error " -> Error mounting device $device for $label" - return 1 - fi - sleep 1 - return 0 -} - -get_file_hash() { - if [[ ! $# -eq 2 ]]; then - error "get_file_size need 2 arguments, $# provided : '$*'" - return 1 - fi - local file - local file_size - - file=$1 - file_size=${2:-1} - if ((file_size != -1)); then - if [[ -f "$file" ]]; then - if ((file_size > 0)); then - if ((file_size > 2000000)); then - #calculate - local tmp_file - tmp_file=mktemp - head -c 1MB "$file" >"$tmp_file" - tail -c 1MB "$file" >>"$tmp_file" - printf "%s" "$(md5sum "$tmp_file" | cut -d" " -f 1)" - rm "$tmp_file" - else - printf "%s" "$(md5sum "$file" | cut -d" " -f 1)" - fi - return - fi - fi - fi - printf "%s" -1 -} - -move_file() { - if [[ ! $# -eq 2 ]]; then - error "move_file need 2 arguments, $# provided : '$*'" - return 1 - fi - local source="$1" - local destination="$2" - - printf "Move %s to %s\n" "$source" "$destination" - if [[ ! -d "${destination%/*}" ]]; then - error "$destination directory does not exists" - return 1 - fi - - if ! mv "$source" "$destination"; then - error "Error moving $source file, file seems to not exists" - return 1 - fi - return 0 -} - -get_file_size() { - if [[ ! $# -eq 1 ]]; then - error "get_file_size need 2 arguments, $# provided : '$*'" - return 1 - fi - local file - file=$1 - if [[ -f "$file" ]]; then - wc -c <"$file" - return - fi - printf "%s" -1 -} - -insert_media() { - if [[ ! $# -eq 2 ]]; then - error "insert_media need 2 arguments, $# provided : '$*'" - return 1 - fi - local filename filesize filehash tag - filename="$1" - tag="$2" - if [[ ! -f "$filename" ]]; then - error "File $filename not found, can't insert media" - return 1 - fi - if [[ -z "$tag" ]]; then - error "Tag not defined, can't insert media (filename: $filename)" - return 1 - fi - filesize=$(get_file_size "$filename") - filehash=$(get_file_hash "$filename" "$filesize") - if ! sed -i \ - -e "s#\[\[${tag}\]\]#${filename}#g" \ - -e "s#\[\[${tag}_filesize\]\]#${filesize}#g" \ - -e "s#\[\[${tag}_filehash\]\]#${filehash}#g" \ - "${folder}/montage.kdenlive"; then - error "sed command error on insert media!" - return 1 - fi - return 0 -} - -function main() { - process_args "$@" - - base_dir="${HOME}/medias/videos/sambab" - key_label=${key_label:-"SAMBAB"} - recorder_label=${recorder_label:-"LS-100"} - - printf "Creation de la conférence de %s\n" "$conf" - cd ~/medias/videos/sambab || exit 1 - - #Get las friday date for creating folder - friday=$(date --date='last Friday' +"%Y.%m.%d") - - #Add basedir, then I have my directory - folder="${base_dir}/${friday}-${conf// /_}" - - # create it - mkdir "${folder}/"{rushes,audio,titles} -p || die "folder creation failed" - - cp "${base_dir}/logo_amis.svg" "${folder}/titles" || die "SVG copy failed!" - cp "${base_dir}/template.kdenlive" "${folder}/montage.kdenlive" || die "Template copy failed!" - - inkscape_date=$(LC_ALL=fr_FR.UTF-8 date --date='last Friday' +"%A %d %B %Y") - - printf "Put Name on title\n" - sed -i "s/\[\[conf\]\]/${conf//_/ }/g" "${folder}/titles/logo_amis.svg" || die "Change text on credits screen failed!" - - printf "Put date on title\n" - sed -i "s/\[\[date\]\]/${inkscape_date}/g" "${folder}/titles/logo_amis.svg" || die "Change date failed!" - - printf "Export SVG title \n" - inkscape --export-type="png" "${folder}/titles/logo_amis.svg" || die "SVG export failed" - - printf "Importing PNG File in %s/montage.kdenlive \n" "$folder" - insert_media "$folder/titles/logo_amis.png" "logo" - - ## Get file from USB key - if mount_device "$key_label"; then - move_file "/run/media/${USER}/${key_label}/RECORD/EXREC/"*.MP3 "${folder}/audio/audio.mp3" - move_file "/run/media/${USER}/${key_label}/$(date --date='last Friday' +'%Y-%m-%d')"\ *.mkv "${folder}/rushes/obs.mkv" - mount_device "$key_label" 1 - fi - - ## Get audio file from RECORDER - if mount_device "$recorder_label"; then - move_file "/run/media/${USER}/${recorder_label}/RECORDER/FOLDER_A/"VOC_*.wav "${folder}/audio/recorder.wav" - fi - - move_file "$HOME/downloads/$(date --date='last Friday' +'%Y%m%d')"_*.mp4 "${folder}/rushes/presensation.mp4" - - insert_media "${folder}/audio/audio.mp3" audio - insert_media "${folder}/rushes/obs.mkv" video - insert_media "${folder}/audio/recorder.wav" audio_recorder - insert_media "${folder}/rushes/presensation.mp4" video_intro - - printf "Change root folder in montage.kdenlive to %s\n" "$folder" - sed -i -e "s#\[\[root_folder\]\]#${folder}#g" "${folder}/montage.kdenlive" -} - -main "$@" -exit 0 diff --git a/nixos/default.nix b/nixos/default.nix index d8a2103..983345b 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -1,4 +1,4 @@ -{ pkgs, stateVersion, hostname, ... }: +{ inputs, pkgs, stateVersion, hostname, username, hostConfig, ... }: { imports = [ # Include the results of the hardware scan. ../hosts/${hostname}/hardware-configuration.nix @@ -15,9 +15,11 @@ ./includes/system/overlay.nix ]; + nixpkgs.config.allowUnfree = true; -boot.kernelPackages = pkgs.linuxPackages_latest; + + boot.kernelPackages = pkgs.linuxPackages_latest; networking.hostName = hostname; console = { @@ -28,10 +30,32 @@ boot.kernelPackages = pkgs.linuxPackages_latest; useXkbConfig = true; # use xkbOptions in tty. }; + environment.systemPackages = with pkgs; [ git zsh ]; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { + inherit hostConfig; + inherit hostname; + }; + + # NixOS system-wide home-manager configuration + sharedModules = [ + inputs.sops-nix.homeManagerModules.sops + ]; + + users.${username} = { + home.stateVersion = stateVersion; + imports = [ + ../home-manager/base.nix + ]; + }; + }; + system.stateVersion = stateVersion; } diff --git a/taskfile.yaml b/taskfile.yaml new file mode 100644 index 0000000..02f28c8 --- /dev/null +++ b/taskfile.yaml @@ -0,0 +1,54 @@ +--- +version: "3" +set: [errexit, pipefail, nounset] +shopt: [globstar] +tasks: + check:sh: + cmds: + - shellcheck **/*.sh + sources: + - "**/*.sh" + check:typos: + cmds: + - typos . + check:flake: + cmds: + - nix flake check + sources: + - "**/*.nix" + + build:*: + vars: + TARGET: "{{index .MATCH 0}}" + cmds: + - nixos-rebuild --flake .#{{.TARGET}} build + + switch:*: + vars: + TARGET: "{{index .MATCH 0}}" + cmds: + - doas nixos-rebuild --flake .#{{.TARGET}} switch + + test:*: + vars: + TARGET: "{{index .MATCH 0}}" + cmds: + - doas nixos-rebuild --flake .#{{.TARGET}} test + + home:build:*: + vars: + TARGET: "{{index .MATCH 0}}" + cmds: + - home-manager build --flake .#{{.TARGET}} + + home:test:*: + vars: + TARGET: "{{index .MATCH 0}}" + cmds: + - home-manager test --flake .#{{.TARGET}} + + home:switch:*: + vars: + TARGET: "{{index .MATCH 0}}" + cmds: + - home-manager switch --flake .#{{.TARGET}}