From c6de5f2e8b67705932b26a0434a497380f7770eb Mon Sep 17 00:00:00 2001 From: pegasust Date: Wed, 9 Nov 2022 11:35:28 +0000 Subject: [PATCH] sandbox to add fromYaml to a flake --- home-nix/flake.lock | 53 ++++++++++++++++++++++++++++- home-nix/flake.nix | 17 ++++++--- home-nix/fromYamlSandbox/flake.lock | 44 ++++++++++++++++++++++++ home-nix/fromYamlSandbox/flake.nix | 22 ++++++++++++ home-nix/home.nix | 36 ++++++++++++++------ lib-nix/default.nix | 4 +++ lib-nix/fromYaml | 1 + 7 files changed, 161 insertions(+), 16 deletions(-) create mode 100644 home-nix/fromYamlSandbox/flake.lock create mode 100644 home-nix/fromYamlSandbox/flake.nix create mode 100644 lib-nix/default.nix create mode 160000 lib-nix/fromYaml diff --git a/home-nix/flake.lock b/home-nix/flake.lock index 397a9ec..4849cac 100644 --- a/home-nix/flake.lock +++ b/home-nix/flake.lock @@ -30,6 +30,21 @@ "type": "github" } }, + "flake-utils_3": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -101,12 +116,48 @@ "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1665296151, + "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", "home-manager": "home-manager", "nixgl": "nixgl", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1667943215, + "narHash": "sha256-FSD8RIL85Kbq3wVzxzYPuWkXtNaW/HldGpVVRDoPpnY=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "01a89f997e49dd624c7f94813feceda63e91ee2e", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } }, "utils": { diff --git a/home-nix/flake.nix b/home-nix/flake.nix index 6760469..4972a3c 100644 --- a/home-nix/flake.nix +++ b/home-nix/flake.nix @@ -8,14 +8,20 @@ }; flake-utils.url = "github:numtide/flake-utils"; nixgl.url = "github:guibou/nixGL"; + rust-overlay.url = "github:oxalica/rust-overlay"; }; - outputs = { nixpkgs, home-manager, nixgl, ... }: + outputs = { nixpkgs, home-manager, nixgl, rust-overlay, flake-utils, ... }: let system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}.appendOverlays [nixgl.overlay]; + overlays = [ nixgl.overlay rust-overlay.overlays.default ]; + # pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays; + pkgs = import nixpkgs { inherit system overlays; }; + lib = (import ../lib-nix { inherit pkgs; lib = pkgs.lib; }); in - { + rec { + inherit pkgs; + inherit lib; homeConfigurations.nixos = home-manager.lib.homeManagerConfiguration { inherit pkgs; modules = [ @@ -25,6 +31,7 @@ # we migrate this from in-place modules to allow flexibility # in this case, we can add "home" to input arglist of home.nix extraSpecialArgs = { + inherit lib; myHome = { username = "nixos"; homeDirectory = "/home/nixos"; @@ -37,6 +44,7 @@ ./home.nix ]; extraSpecialArgs = { + # inherit lib; myHome = { username = "ubuntu_admin"; homeDirectory = "/home/ubuntu_admin"; @@ -49,10 +57,11 @@ ./home.nix ]; extraSpecialArgs = { + # inherit lib; myHome = { username = "hwtr"; homeDirectory = "/home/hwtr"; - packages = [pkgs.nixgl.nixGLIntel]; + packages = [ pkgs.nixgl.nixGLIntel ]; shellAliases = { nixGL = "nixGLIntel"; }; diff --git a/home-nix/fromYamlSandbox/flake.lock b/home-nix/fromYamlSandbox/flake.lock new file mode 100644 index 0000000..65e798e --- /dev/null +++ b/home-nix/fromYamlSandbox/flake.lock @@ -0,0 +1,44 @@ +{ + "nodes": { + "from-yaml": { + "flake": false, + "locked": { + "lastModified": 1667993008, + "narHash": "sha256-X5RWyebq+j56mUGGCmZTVcJBy6Y/QgFEMHklaz+GOt0=", + "owner": "pegasust", + "repo": "fromYaml", + "rev": "23d2616051f5a781dcfe2915a526925fd9cdd08c", + "type": "github" + }, + "original": { + "owner": "pegasust", + "repo": "fromYaml", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1667811565, + "narHash": "sha256-HYml7RdQPQ7X13VNe2CoDMqmifsXbt4ACTKxHRKQE3Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "667e5581d16745bcda791300ae7e2d73f49fff25", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "from-yaml": "from-yaml", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/home-nix/fromYamlSandbox/flake.nix b/home-nix/fromYamlSandbox/flake.nix new file mode 100644 index 0000000..c097de7 --- /dev/null +++ b/home-nix/fromYamlSandbox/flake.nix @@ -0,0 +1,22 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + from-yaml ={ + url = "github:pegasust/fromYaml"; + flake = false; + }; + }; + outputs = {nixpkgs,from-yaml, ...}: let + system = "x86_64-linux"; + pkgs = import nixpkgs {inherit system;}; + lib = { + fromYaml = import "${from-yaml}/fromYaml.nix" {lib = pkgs.lib;}; + }; + in { + inherit nixpkgs; + inherit from-yaml; + inherit lib; + fromYamlFn = lib.fromYaml; + }; +} + diff --git a/home-nix/home.nix b/home-nix/home.nix index 180abd3..f9f16ee 100644 --- a/home-nix/home.nix +++ b/home-nix/home.nix @@ -1,5 +1,10 @@ # myHome is injected from extraSpecialArgs in flake.nix -{ config, pkgs, myHome, ... }: +{ config +, pkgs +, myHome +# , lib +, ... +}: { home = { username = myHome.username; @@ -7,12 +12,17 @@ stateVersion = myHome.stateVersion or "22.05"; }; home.packages = [ - pkgs.htop pkgs.ripgrep pkgs.gcc pkgs.fd pkgs.zk pkgs.unzip - pkgs.rustc pkgs.cargo - pkgs.nodejs-18_x + pkgs.htop + pkgs.ripgrep + pkgs.gcc + pkgs.fd + pkgs.zk + pkgs.unzip + pkgs.rust-bin.nightly.latest.default + pkgs.nodejs-18_x pkgs.rust-analyzer pkgs.stdenv.cc.cc.lib - ] ++ (myHome.packages or []); + ] ++ (myHome.packages or [ ]); nixpkgs.config.allowUnfree = true; ## Configs ## @@ -22,6 +32,7 @@ ## Programs ## programs.alacritty = myHome.programs.alacritty or { enable = true; + # settings = lib.fromYaml builtins.readFile ../alacritty/alacritty.yml; }; programs.direnv = { enable = true; @@ -61,7 +72,7 @@ shellAliases = { nix-rebuild = "sudo nixos-rebuild switch"; hm-switch = "home-manager switch --flake"; - } // (myHome.shellAliases or {}); + } // (myHome.shellAliases or { }); history = { size = 10000; path = "${config.xdg.dataHome}/zsh/history"; @@ -75,13 +86,16 @@ enable = true; lfs.enable = true; aliases = { - a="add"; c="commit"; ca="commit --ammend"; cm="commit -m"; - lol="log --graph --decorate --pretty=oneline --abbrev-commit"; - lola="log --graph --decorate --pretty=oneline --abbrev-commit --all"; - sts="status"; + a = "add"; + c = "commit"; + ca = "commit --ammend"; + cm = "commit -m"; + lol = "log --graph --decorate --pretty=oneline --abbrev-commit"; + lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all"; + sts = "status"; }; extraConfig = { - merge = {tool="vimdiff"; conflictstyle="diff3";}; + merge = { tool = "vimdiff"; conflictstyle = "diff3"; }; }; # why is this no longer valid? # pull = { rebase=true; }; diff --git a/lib-nix/default.nix b/lib-nix/default.nix new file mode 100644 index 0000000..15541e9 --- /dev/null +++ b/lib-nix/default.nix @@ -0,0 +1,4 @@ +{pkgs, lib, ...}@flake_import: +{ + fromYaml = import ./fromYaml/fromYaml.nix {inherit lib;}; +} diff --git a/lib-nix/fromYaml b/lib-nix/fromYaml new file mode 160000 index 0000000..f31858f --- /dev/null +++ b/lib-nix/fromYaml @@ -0,0 +1 @@ +Subproject commit f31858f94e3f05d4982754eab0e1f427d1ca2497