❄ Personal NixOS Flake Manager
nixos home-manager go nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(rui): editor and flake file configuration

Fuwn e7608534 368733e1

+38 -10
+38 -10
rui.go
··· 11 11 ) 12 12 13 13 type Configuration struct { 14 - Notify bool `json:"notify"` 14 + Notify bool `json:"notify"` 15 + Editor string `json:"editor"` 16 + Flake string `json:"flake"` 15 17 } 16 18 17 19 var configuration Configuration ··· 110 112 user = os.Getenv("USER") 111 113 } 112 114 115 + flake := configuration.Flake 116 + 117 + if flake == "" { 118 + flake = os.Getenv("FLAKE") 119 + } 120 + 113 121 err = Command("home-manager", append([]string{"switch", 114 - "--flake", fmt.Sprintf("%s#%s", os.Getenv("FLAKE"), user)}, 122 + "--flake", fmt.Sprintf("%s#%s", flake, user)}, 115 123 extraArgs...)...) 116 124 } 117 125 ··· 134 142 }, 135 143 }, 136 144 Action: func(c *cli.Context) error { 137 - target := os.Getenv("FLAKE") 145 + flake := configuration.Flake 146 + 147 + if flake == "" { 148 + flake = os.Getenv("FLAKE") 149 + } 150 + 138 151 extraArgs := []string{} 139 152 140 153 if c.Bool("impure") { ··· 142 155 } 143 156 144 157 if user := c.String("user"); user != "" { 145 - target = fmt.Sprintf("%s#%s", target, user) 158 + flake = fmt.Sprintf("%s#%s", flake, user) 146 159 } 147 160 148 161 return Command("home-manager", append([]string{"news", "--flake", 149 - target}, extraArgs...)...) 162 + flake}, extraArgs...)...) 150 163 }, 151 164 }, 152 165 }, ··· 191 204 } 192 205 } 193 206 207 + flake := configuration.Flake 208 + 209 + if flake == "" { 210 + flake = os.Getenv("FLAKE") 211 + } 212 + 194 213 err = Command(escalator, "nixos-rebuild", "switch", "--flake", 195 - fmt.Sprintf("%s#%s", os.Getenv("FLAKE"), hostname)) 214 + fmt.Sprintf("%s#%s", flake, hostname)) 196 215 } 197 216 198 217 if err != nil { ··· 207 226 { 208 227 Name: "edit", 209 228 Action: func(c *cli.Context) error { 210 - editor, err := os.LookupEnv("FLAKE_EDITOR") 229 + var found bool 211 230 212 - if err { 213 - return Command(editor, os.Getenv("FLAKE")) 231 + editor := configuration.Editor 232 + flake := configuration.Flake 233 + 234 + if flake == "" { 235 + flake = os.Getenv("FLAKE") 214 236 } 215 237 216 - return Command(os.Getenv("EDITOR"), os.Getenv("FLAKE")) 238 + if editor == "" { 239 + if editor, found = os.LookupEnv("FLAKE_EDITOR"); !found { 240 + editor = os.Getenv("EDITOR") 241 + } 242 + } 243 + 244 + return Command(editor, flake) 217 245 }, 218 246 }, 219 247 },