Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #54 from ublue-os/53-fixinitcrash
Browse files Browse the repository at this point in the history
fix: state machine
  • Loading branch information
bketelsen authored Mar 23, 2023
2 parents 0b10c19 + 9aa568e commit e4e9e51
Show file tree
Hide file tree
Showing 27 changed files with 663 additions and 306 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ Fleek is a user-friendly wrapper around Nix and Nix Home Manager, but the friend
You need `nix`. We love the [Determinate Systems Installer](https://zero-to-nix.com/), but any `nix` is good. If you're on Fedora Silverblue [this script](https://github.com/dnkmmr69420/nix-with-selinux/blob/main/silverblue-installer.sh) is the good stuff.

Next you'll need `fleek`. Download from the releases link.


## Shoulders

Standing on the shoulders of giants:

- [flake template](https://github.com/Misterio77/nix-starter-configs)
5 changes: 1 addition & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/sh
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-w -extldflags "-static"'
rm -f fleek.1
rm -f fleek.1.gz
./fleek man > fleek.1
gzip fleek.1

2 changes: 1 addition & 1 deletion clean.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

rm ~/.fleek.yml
rm -f ~/.fleek.yml
rm -rf ~/.config/home-manager
rm -rf dist
25 changes: 15 additions & 10 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import (

func NewAddCommand() *cmdr.Command {
cmd := cmdr.NewCommandRun(
fleek.Trans("add.use"),
fleek.Trans("add.long"),
fleek.Trans("add.short"),
app.Trans("add.use"),
app.Trans("add.long"),
app.Trans("add.short"),
add,
).WithBoolFlag(
cmdr.NewBoolFlag(
"program",
"p",
fleek.Trans("add.program"),
app.Trans("add.program"),
false,
)).WithBoolFlag(
cmdr.NewBoolFlag(
"apply",
"a",
fleek.Trans("add.apply"),
app.Trans("add.apply"),
false,
))
cmd.Args = cobra.MinimumNArgs(1)
Expand All @@ -43,25 +43,30 @@ func add(cmd *cobra.Command, args []string) {
apply = true
}
if verbose {
cmdr.Info.Println(fleek.Trans("add.applying"))
cmdr.Info.Println(app.Trans("add.applying"))
}

var err error

for _, p := range args {
if cmd.Flag("program").Changed {
err = config.AddProgram(p)
err = f.config.AddProgram(p)
cobra.CheckErr(err)
} else {
err = config.AddPackage(p)
err = f.config.AddPackage(p)
cobra.CheckErr(err)
}

repo, err := f.Repo()
cobra.CheckErr(err)
err = repo.Commit()
cobra.CheckErr(err)
}
if apply {
flake, err := f.Flake()
cobra.CheckErr(err)
err = flake.Apply()
cobra.CheckErr(err)
}

cmdr.Info.Println(fleek.Trans("add.done"))
cmdr.Info.Println(app.Trans("add.done"))
}
54 changes: 33 additions & 21 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import (

func NewApplyCommand() *cmdr.Command {
cmd := cmdr.NewCommandRun(
fleek.Trans("apply.use"),
fleek.Trans("apply.long"),
fleek.Trans("apply.short"),
app.Trans("apply.use"),
app.Trans("apply.long"),
app.Trans("apply.short"),
apply,
).WithBoolFlag(
cmdr.NewBoolFlag(
"dry-run",
"d",
fleek.Trans("apply.dryRun"),
app.Trans("apply.dryRun"),
false,
)).WithBoolFlag(
cmdr.NewBoolFlag(
"push",
"p",
fleek.Trans("apply.push"),
app.Trans("apply.push"),
false,
))
return cmd
Expand All @@ -41,24 +41,28 @@ func apply(cmd *cobra.Command, args []string) {
if cmd.Flag("push").Changed {
push = true
}
if behind {
cmdr.Error.Println(fleek.Trans("apply.behind"))
if f.flakeStatus == FlakeBehind {
cmdr.Error.Println(app.Trans("apply.behind"))
return

}
if verbose {
cmdr.Info.Println(fleek.Trans("apply.writingConfig"))
cmdr.Info.Println(app.Trans("apply.writingConfig"))
}
// only re-apply the templates if not `ejected`
if !config.Ejected {
if !f.config.Ejected {
if verbose {
cmdr.Info.Println(fleek.Trans("apply.writingFlake"))
cmdr.Info.Println(app.Trans("apply.writingFlake"))
}
err := flake.Write()
flake, err := f.Flake()
cobra.CheckErr(err)
err = flake.Write(false)
cobra.CheckErr(err)
repo, err := f.Repo()
cobra.CheckErr(err)
err = repo.Commit()
if err != nil {
cmdr.Error.Println(fleek.Trans("apply.commitError"), err)
cmdr.Error.Println(app.Trans("apply.commitError"), err)
}
cobra.CheckErr(err)

Expand All @@ -69,24 +73,32 @@ func apply(cmd *cobra.Command, args []string) {
dry = true
}
if !dry {
cmdr.Info.Println(fleek.Trans("apply.applyingConfig"))
err := flake.Apply()
cmdr.Info.Println(app.Trans("apply.applyingConfig"))
flake, err := f.Flake()
cobra.CheckErr(err)
err = repo.Commit()
err = flake.Apply()
cobra.CheckErr(err)
r, err := f.Repo()
cobra.CheckErr(err)
err = r.Commit()
if err != nil {
cmdr.Error.Println(fleek.Trans("apply.commitError"), err)
cmdr.Error.Println(app.Trans("apply.commitError"), err)
}
} else {
cmdr.Info.Println(fleek.Trans("apply.dryApplyingConfig"))
err := flake.Check()
cmdr.Info.Println(app.Trans("apply.dryApplyingConfig"))
flake, err := f.Flake()
cobra.CheckErr(err)
err = flake.Check()
cobra.CheckErr(err)
}
if push {
cmdr.Info.Println(fleek.Trans("apply.pushing"))
err := repo.Push()
cmdr.Info.Println(app.Trans("apply.pushing"))
repo, err := f.Repo()
cobra.CheckErr(err)
err = repo.Push()
cobra.CheckErr(err)
}

cmdr.Success.Println(fleek.Trans("apply.done"))
cmdr.Success.Println(app.Trans("apply.done"))

}
19 changes: 10 additions & 9 deletions cmd/eject.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ package cmd

import (
"github.com/spf13/cobra"
"github.com/ublue-os/fleek/core"
"github.com/vanilla-os/orchid/cmdr"
)

func NewEjectCommand() *cmdr.Command {
cmd := cmdr.NewCommandRun(
fleek.Trans("eject.use"),
fleek.Trans("eject.long"),
fleek.Trans("eject.short"),
app.Trans("eject.use"),
app.Trans("eject.long"),
app.Trans("eject.short"),
eject,
)
return cmd
Expand All @@ -22,16 +21,18 @@ func NewEjectCommand() *cmdr.Command {
// initCmd represents the init command
func eject(cmd *cobra.Command, args []string) {

ok, err := cmdr.Confirm.Show(fleek.Trans("eject.confirm"))
ok, err := cmdr.Confirm.Show(app.Trans("eject.confirm"))
cobra.CheckErr(err)

if ok {
cmdr.Info.Println(fleek.Trans("eject.start"))
err := flake.Write()
cmdr.Info.Println(app.Trans("eject.start"))
flake, err := f.Flake()
cobra.CheckErr(err)
err = core.WriteEjectConfig()
err = flake.Write(true)
cobra.CheckErr(err)
cmdr.Info.Println(fleek.Trans("eject.complete"))
err = f.config.Eject()
cobra.CheckErr(err)
cmdr.Info.Println(app.Trans("eject.complete"))
}

}
Loading

0 comments on commit e4e9e51

Please sign in to comment.